Libraries¶
Falls mit einer venv gearbeitet wird, muss die venv aktiviert sein. Dies kann über den Befehl venv\\Scripts\\activate ausgeführt werden.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
from datasets import Dataset
import langdetect
import re
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from collections import Counter
from collections import OrderedDict
from langdetect import detect
import torch
import sys
import os
import warnings
warnings.filterwarnings('ignore')
sys.path.append(os.path.abspath("../"))
import src.utilities as u
import src.plots as p
import src.constants as c
c_stopwords = c.custom_stopwords
from src.utilities import TextCleaner
from src.credentials import AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import Chroma
from langchain_openai import AzureOpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings
import chromadb
from src.evaluation import RAGAS_Evaluator
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI
from langchain_openai import AzureChatOpenAI
from langchain_core.runnables import RunnableLambda
from langchain_core.documents import Document
from langchain.schema.runnable import RunnableMap
from langchain_core.prompts import ChatPromptTemplate
from ragas.metrics import faithfulness, answer_relevancy, context_precision
from ragas import evaluate
from datasets import Dataset
from difflib import SequenceMatcher
u.generate_toc('../doc/MC1.ipynb')
Inhaltsverzeichnis¶
- NPR MC1 RAG
- Libraries
- Kurzbeschreibung:
- EDA
- Daten kennen lernen
- Daten Laden
- Untersuchen der ersten Erkenntnisse
- Sprache überprüfen
- Text Bereinigen
- Duplikate entfernen
- Wordcloud 2.0
- Titel an den Content anfügen
- Datensatz mit 1000 Zeilen
- Chunking
- Tokenisierung
- Embeddings
- Chroma Daten
- Retrieval-Modul (Suche & Ranking) & Generator-Modul (Antwortgenerierung)
- Evaluator-Modul (Qualitätsprüfung & Optimierung)
- Evaluierte Metriken
- Durchführung des Experiments
- Evaluierung Embeddings
- Embedding Evaluation: Übersicht der Mittelwerte
- Evaluierung Retrieval
- Retriever- und Prompt-Kombinationen: Übersicht der Mittelwerte
- Evaluierung Temperatur
- Temperature Evaluation: Übersicht der Mittelwerte
- Manuell plausability Check
- Fazit
- Weitere Überlegungen
Kurzbeschreibung:¶
Die Mini-Challenge befasst sich mit der Konzeption, Implementierung und Evaluierung eines Retrieval-Augmented-Generation-(RAG)-Systems. Ziel dieses Systems ist es, die Leistungsfähigkeit eines Sprachmodells durch die Integration externer Wissensquellen zu erweitern, um präzisere und kontextuell fundierte Antworten zu generieren. Im Rahmen der Challenge sind die Teilnehmenden dazu aufgefordert, zentrale Systemkomponenten – darunter Module zur Datenaufnahme, zum Information Retrieval sowie zur Textgenerierung – zu entwickeln und hinsichtlich ihrer Leistungsfähigkeit zu überprüfen. Die Evaluation erfolgt sowohl durch automatische Bewertungsverfahren als auch durch manuelle Qualitätsbeurteilungen. Übergeordnetes Ziel ist es, das Verständnis für Methoden der natürlichen Sprachverarbeitung (Natural Language Processing, NLP) zu vertiefen und die praktischen Kompetenzen in der Entwicklung und Bewertung fortgeschrittener Sprachsysteme zu stärken.
Hinweis:¶
Für die vollständige Ausführung des Projekts ist die vorherige Installation sämtlicher in der Datei requirements.txt aufgeführter Abhängigkeiten erforderlich. Darüber hinaus muss sich das Projekt lokal auf dem System befinden. Die generierten Embeddings sind im lokalen Projektordner im Verzeichnis src abzulegen, um eine fehlerfreie Ausführung sicherzustellen.
Sources¶
GitHub Repository Structure (Best Practices)
Notebooks ohne Output pushen (Vermeidung von Merge-Konflikten)
Jupyter Book erstellen (HTML oder PDF)
Retrieval-Augmented Generation (RAG) – Beispiel
Chunking und Tokenization
- 5 Levels of Text Splitting (GitHub)
- 5 Chunking Strategies for RAG (Blog)
- Chunkviz - Visualisierung
- OpenAI Tokenizer
- What is Tokenization? (DataCamp Blog)
Chroma DB
Wordcloud & NLTK
RAG Evaluation (Video und Beispiel)
EDA¶
Daten kennen lernen¶
Um den Datensatz kennen zu lernen und dabei die verschiedenen Technologien im Zusammenhang mit textuellen Daten und Modellen zu verstehen, werden wir verschiedene Pakete anwenden.
Inhalt:
langdetectCounterTextCleanerWordCloud
Daten Laden¶
Die Daten, welche wir aus einer .csv Datei laden, welche von einer Website stammen. Mit diesen Daten möchten wir später unsere Fragen beantworten.
Datenbeschreibung¶
- id Unique ID des Artikels
- title Title des Artikels
- date Erscheinungsdatum des Artikels
- author Name des Autors
- content Inhalt des Artikels
- domain von wo der Artikel kommt
- url Webadresse (wie man den Artikel finden kann)
file_path = "../data_mc1/"
file_name_train = 'cleantech_media_dataset_v3_2024-10-28.csv'
column_names = ["id", "title", "date", "author", "content", "domain", "url"]
df_train = pd.read_csv(file_path+file_name_train, delimiter=",", names=column_names, skiprows=1, encoding="utf-8")
df_train.head()
| id | title | date | author | content | domain | url | |
|---|---|---|---|---|---|---|---|
| 0 | 93320 | XPeng Delivered ~100,000 Vehicles In 2021 | 2022-01-02 | NaN | ['Chinese automotive startup XPeng has shown o... | cleantechnica | https://cleantechnica.com/2022/01/02/xpeng-del... |
| 1 | 93321 | Green Hydrogen: Drop In Bucket Or Big Splash? | 2022-01-02 | NaN | ['Sinopec has laid plans to build the largest ... | cleantechnica | https://cleantechnica.com/2022/01/02/its-a-gre... |
| 2 | 98159 | World’ s largest floating PV plant goes online... | 2022-01-03 | NaN | ['Huaneng Power International has switched on ... | pv-magazine | https://www.pv-magazine.com/2022/01/03/worlds-... |
| 3 | 98158 | Iran wants to deploy 10 GW of renewables over ... | 2022-01-03 | NaN | ['According to the Iranian authorities, there ... | pv-magazine | https://www.pv-magazine.com/2022/01/03/iran-wa... |
| 4 | 31128 | Eastern Interconnection Power Grid Said ‘ Bein... | 2022-01-03 | NaN | ['Sign in to get the best natural gas news and... | naturalgasintel | https://www.naturalgasintel.com/eastern-interc... |
u.missing_value_stats(df_train)
| NaN/None (%) | 0-Werte (%) | |
|---|---|---|
| id | 0.0 | 0.0 |
| title | 0.0 | 0.0 |
| date | 0.0 | 0.0 |
| author | 100.0 | 0.0 |
| content | 0.0 | 0.0 |
| domain | 0.0 | 0.0 |
| url | 0.0 | 0.0 |
Der Spalte author ist vollständig fehlend, nach Ansehen des Artikels ist schnell ersichtlich, dass dieser über Webscraping aus den Artikeln extrahiert werden könnte. Da aber in den Evaluierungsdaten keine Frage bezüglich des Authors vorhanden ist wird diese nun entfernt. Allerdings könnte diese Information Wert liefern im Bezug auf Ähnlichkeitsberechnung von Inhalten der Artikeln, dies könnte später erneut überprüft werden. Vorerst wird die Spalte author erntfernt.
df_train = df_train.drop(columns=["author"])
df_train.dtypes
id int64 title object date object content object domain object url object dtype: object
Nachdem die offensichtlichen Bereinigungen vorgenommen wurden, möchten wir einen Überblick über wichtigsten Metriken.
Dabei werden die Objekt-Spalten in folgenden Kategorien angezeigt:
count: Anzahl der nicht-leeren Werteunique: Anzahl der einzigartigen Wertetop: Der am häufigsten vorkommende Wertfreq: Die Häufigkeit dieses Wertes
Wir fügen den Zeilenumbruch für die Ausgabe ein, damit der gesamte Text sichtbar wird.
styled = (
df_train.describe(include=[object])
.applymap(u.shorten_text) # auf alle Zellen anwenden
.style
.set_properties(**{
'white-space': 'pre-wrap', # \n sichtbar
'max-width': '300px', # Zellbreite beschränken
'font-family': 'monospace', # bessere Darstellung
})
)
styled
| title | date | content | domain | url | |
|---|---|---|---|---|---|
| count | 20111 | 20111 | 20111 | 20111 | 20111 |
| unique | 20016 | 979 | 20068 | 25 | 20111 |
| top | About David J. Cross | 2023-06-13 | ["By the end of 2022, 37% of single-family homes a cross the five islands Hawaiian Electric serves ha d rooftop solar, Oahu's first grid-scale solar and storage project was online, and the state's last remaining coal plant was retired. That's the kind ... | energy-xprt | https://cleantechnica.com/2022/01/02/xpeng-deliver ed-100000-vehicles-in-2021/ |
| freq | 13 | 1812 | 3 | 4181 | 1 |
Wir sehen nun, dass:
- Total Reihen es sind 20111 Reihen vorhanden
- title die meisten Artikel haben ihren eigenen Titel
- date es sind nur 979 Datum vorhanden, was im Umkehrschluss bedeutet, dass mehrere Artikel das gleiche Datum tragen
- content es sind mehr einzigartige Artikel vorhanden als Titel. Die Einzigartigkeit könnte auch mit der Darstellung der Website zusammen hängen. Daher kann es sein, dass nach der Bereinigung des Textes mehrere Artikel gleich sind als jetzt.
- domain es gibt nur 25 verschiedene Domains was wiederum bedeutet, dass diese Domains sehr viele Artikel enthalten
- url jede Zeile stammt von einer anderen url.
- top diese Information sagt uns welcher Titel (About David J. Cross), Artikel, welche Domain (enery-xprt), url oder welches Datum (13.08.2023) am häufigsten vorkommt und somit wo und wie wir nach dieser Häufigkeit suchen müssen
Anpassen der Datentypen
id: int64 -> bleibt int64
title: object -> string
date: object -> datetime
content: object -> string
domain: object -> string
url: object -> string
Datumsformat erstellen
# Datentypen korrigieren
df_train["date"] = pd.to_datetime(df_train["date"], errors="coerce") # Falls ungültige Datumswerte vorhanden
df_train.dtypes
id int64 title object date datetime64[ns] content object domain object url object dtype: object
Untersuchen der ersten Erkenntnisse¶
Die ersten Erkenntnisse möchten wir nun genauer unter die Lupe nehmen und einige Analysen über die Top-Werte erstellen.
Artikel pro Domain¶
Als erstes werden wir schauen, wieviele Artikel pro Domain vorhanden sind. Dazu zählen wir die Artikel pro Domain.
articles_per_domain = df_train.groupby("domain").size().reset_index(name="count")
articles_per_domain = articles_per_domain.sort_values(by="count", ascending=False)
articles_per_domain.reset_index(drop=True, inplace=True)
p.bar_plot(articles_per_domain, "domain", "count", "Anzahl Artikel pro Domain", "Domain", "Anzahl Artikel", xrotation=45, ha_xrotation='right')
Analyse: Anzahl Artikel pro Domain¶
Das Balkendiagramm mit dem Titel „Anzahl Artikel pro Domain“ zeigt, wie stark die Artikelverteilung auf bestimmte Domains konzentriert ist. Die Daten stammen offenbar aus dem Bereich erneuerbare Energien oder technologische Fachportale.
Top-Domains mit hoher Artikelanzahl¶
An der Spitze stehen fünf Domains mit besonders vielen Artikeln:
- energy-xprt: 4181 Artikel
- pv-magazine: 3093 Artikel
- azocleantech: 2488 Artikel
- cleantechnica: 2089 Artikel
- pv-tech: 1969 Artikel
Diese fünf Plattformen allein veröffentlichen zusammen über 13.800 Artikel. Das spricht für eine starke redaktionelle Aktivität und eine klare thematische Fokussierung auf Energie- und Technologiethemen.
Ab dem sechsten Platz, vertreten durch thinkgeoenergy mit 1052 Artikeln, ist ein starker Rückgang zu erkennen. Die meisten weiteren Domains bewegen sich im Bereich von 500 bis 1000 Artikeln. Danach fällt die Zahl der veröffentlichten Beiträge deutlich ab.
Eine Vielzahl kleinerer Domains, etwa ecofriend, all-energy, storagexpo oder biofuels-news, veröffentlicht jeweils weniger als 100 Artikel. Einzelne Domains, wie „biofuels-news“, bringen es sogar nur auf einen einzigen Artikel. Dies deutet auf Randakteure oder sehr wenig aktive Plattformen hin.
Verteilungsmuster und Interpretation¶
Das dargestellte Muster folgt dem Prinzip des sogenannten Power-Law oder „Long Tail“: Wenige große Anbieter publizieren sehr viele Inhalte, während eine Vielzahl kleinerer Akteure nur wenige Beiträge liefert. Solche Verteilungen sind typisch für digitale Medienökosysteme, in denen sich Sichtbarkeit und Produktion stark auf einige zentrale Plattformen konzentrieren.
Mögliche Ursachen für die ungleiche Verteilung¶
Drei zentrale Faktoren könnten diese Unterschiede erklären:
- Themenspezialisierung: Plattformen wie „energy-xprt“ und „pv-magazine“ sind vermutlich stark auf bestimmte Technologiebereiche fokussiert.
- Ressourcenverfügbarkeit: Größere Domains verfügen oft über mehr Personal, eine internationale Ausrichtung und höhere Publikationsfrequenz.
- Zielgruppenstrategie: Kleinere Seiten bedienen möglicherweise eng gefasste Zielgruppen oder spezifische Märkte mit geringerem Publikationsbedarf.
Anzahl Artikel zu Top-Titel¶
articles_per_title_top_15 = df_train.groupby("title").size().reset_index(name="count")
articles_per_title_top_15 = articles_per_title_top_15.sort_values(by="count", ascending=False).head(15)
articles_per_title_top_15.reset_index(drop=True, inplace=True)
p.bar_plot(articles_per_title_top_15, "title", "count", "Anzahl Artikel pro Titel", "Titel", "Anzahl Artikel", xrotation=45, ha_xrotation='right', height_offset=0)
Anzahl pro Domain mit dem Titel 'About David J. Cross'¶
Ob verschiedene Domains Artikel mit dem Titel 'About David J. Cross' veröffentlicht haben möchten wir hier untersuchen.
article_count_per_title = df_train[df_train["title"] == "About David J. Cross"].groupby("domain").size().reset_index(name="count")
article_count_per_title = article_count_per_title.sort_values(by="count", ascending=False)
article_count_per_title.reset_index(drop=True, inplace=True)
article_count_per_title
| domain | count | |
|---|---|---|
| 0 | azocleantech | 13 |
Es nur eine Domain, die alle Veröffentlichungen zu diesem Titel gemacht hta. Die "normale" Duplikatensuche keine Ergebnisse lieferte, könnte es sein, dass es sich hier um kleinere Unterschiede beim Inhalt (updates), unterschiedliche Veröffentlichungs-Daten oder verschiedene URLs handeln. Dies wollen wir genauer untersuchen.
article_count_per_title = df_train[df_train["title"] == "About David J. Cross"]
u.styled_text(article_count_per_title)
| id | title | date | content | domain | url | |
|---|---|---|---|---|---|---|
| 1721 | 21198 | About David J. Cross | 2022-05-26 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=6 |
| 6940 | 22486 | About David J. Cross | 2023-05-04 00:00:00 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=4 |
| 6941 | 22487 | About David J. Cross | 2023-05-04 00:00:00 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=2 |
| 6942 | 22488 | About David J. Cross | 2023-05-04 00:00:00 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=11 |
| 7107 | 22482 | About David J. Cross | 2023-05-04 00:00:00 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | azocleantech | https://www.azocleantech.com/authors/david-cross |
| 7110 | 22485 | About David J. Cross | 2023-05-04 00:00:00 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=3 |
| 13074 | 22798 | About David J. Cross | 2023-08-19 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=13 |
| 13076 | 22800 | About David J. Cross | 2023-08-19 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=12 |
| 13081 | 22807 | About David J. Cross | 2023-08-19 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=5 |
| 13098 | 22814 | About David J. Cross | 2023-08-20 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=9 |
| 13104 | 22809 | About David J. Cross | 2023-08-20 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=8 |
| 13105 | 22808 | About David J. Cross | 2023-08-20 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=7 |
| 13217 | 22852 | About David J. Cross | 2023-08-24 00:00:00 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | azocleantech | https://www.azocleantech.com/authors/david-cross?p age=10 |
Die URLs unterscheiden sich insofern, dass jeweils eine andere Page angegeben ist. Die Inhalte scheinen gleich oder sehr ähnlich zu sein. Wir werden nach dem Bereinigungsschritt, bei dem unter anderem die webseitentypischen Textbausteine, wie zum Beispiel: ['We use cookies to enhance your experience. By co ntinuing to browse....` entfernt werden, nochmals auf Doppelte Inhalte überprüfen.
Anzahl Artikel pro Top-Datum¶
# nach Datum gruppieren und Anzahl Artikel zählen, absteigend sortieren
articles_per_date = df_train.groupby("date").size().reset_index(name="count")
articles_per_date_sorted = articles_per_date.sort_values(by="count", ascending=False)
articles_per_date_sorted.head(10)
| date | count | |
|---|---|---|
| 507 | 2023-06-13 | 1812 |
| 508 | 2023-06-14 | 1493 |
| 468 | 2023-05-04 | 430 |
| 509 | 2023-06-15 | 340 |
| 464 | 2023-04-30 | 111 |
| 715 | 2024-01-11 | 53 |
| 622 | 2023-10-07 | 53 |
| 653 | 2023-11-08 | 49 |
| 618 | 2023-10-03 | 49 |
| 579 | 2023-08-25 | 46 |
# Plot erstellen
plt.figure(figsize=(12, 6))
plt.plot(articles_per_date["date"], articles_per_date["count"], linestyle='-')
plt.title("Entwicklung über die Zeit")
plt.xlabel("Datum")
plt.ylabel("Wert")
plt.grid(True)
plt.tight_layout()
plt.xticks(rotation=45)
plt.show()
# Hauptplot
fig, ax = plt.subplots(figsize=(14, 6))
ax.plot(articles_per_date["date"], articles_per_date["count"], label="Count")
ax.set_title("Total Veröffentlichungen über die Zeit")
ax.set_xlabel("Datum")
ax.set_ylabel("Wert")
ax.grid(True)
# Inset-Plot (Zoom auf normalen Bereich)
axins = inset_axes(ax, width="45%", height="55%", loc="upper left", borderpad=2.5)
axins.plot(articles_per_date["date"], articles_per_date["count"])
axins.set_ylim(0, articles_per_date["count"].quantile(0.95)) # 95%-Perzentil als Cutoff
axins.set_title("Zoom (unter 95. Perzentil)")
axins.tick_params(labelsize=8)
plt.tight_layout()
plt.show()
Es gibt Top 5 Daten, die sich deutlich von den anderen unterscheiden. 2023-06-13 mit 1812, 2023-06-14 mit 1493, 2023-05-04 mit 430, 2023-06-15 mit 340, 2023-04-30 mit 111 Veröffentlichungen. Das 95% Perzentil beginnt bei ca. 45 Veröffentlichungen am selben Datum.
Anzahl pro Domain zum Datum vom 13.06.2023¶
Vielleicht können wir herausfinden, warum am 13.06.2023 1812 Artikel veröffentlicht wurden. Dazu werden wir den Datensatz auf das Datum 13.06.2023 filtern, nach Domain filtern und zählen, wieviele Artikel pro Domain veröffentlicht wurden.
article_per_date_and_domain = df_train[df_train["date"] == "2023-06-13"].groupby("domain").size().reset_index(name="count")
article_per_date_and_domain = article_per_date_and_domain.sort_values(by="count", ascending=False)
article_per_date_and_domain.reset_index(drop=True, inplace=True)
article_per_date_and_domain
| domain | count | |
|---|---|---|
| 0 | energy-xprt | 1760 |
| 1 | cleantechnica | 20 |
| 2 | decarbxpo | 12 |
| 3 | pv-magazine | 8 |
| 4 | azocleantech | 3 |
| 5 | solarpowerworldonline | 3 |
| 6 | ecofriend | 1 |
| 7 | energyintel | 1 |
| 8 | pv-tech | 1 |
| 9 | solarindustrymag | 1 |
| 10 | solarpowerportal.co | 1 |
| 11 | thinkgeoenergy | 1 |
Fast alle Artikel wurden von energy-xprt an diesem Tag veröffentlicht. Wir schauen uns die Titel an
energy_xprt_title_count = df_train[
(df_train["date"] == "2023-06-13") & (df_train["domain"] == "energy-xprt")
].groupby("title").size().reset_index(name="count")
energy_xprt_title_count = energy_xprt_title_count.sort_values(by="count", ascending=False)
energy_xprt_title_count.reset_index(drop=True, inplace=True)
energy_xprt_title_count
| title | count | |
|---|---|---|
| 0 | Energy Storage Companies and Suppliers | 6 |
| 1 | Waste-to-Energy Companies and Suppliers | 4 |
| 2 | Incineration Companies and Suppliers | 2 |
| 3 | Solar Data ( Solar Energy) Equipment | 1 |
| 4 | Solar Energy Articles - page 2 | 1 |
| ... | ... | ... |
| 1746 | High Voltage Electricity ( Power Distribution)... | 1 |
| 1747 | High Voltage Cables ( Power Distribution) News | 1 |
| 1748 | High Voltage ( Power Distribution) News | 1 |
| 1749 | High Temperature Batteries Companies and Suppl... | 1 |
| 1750 | zinc alkaline battery ( Battery Energy Storage | 1 |
1751 rows × 2 columns
Aus den Titeln und deren Verteilung ist kein spezieller Grund ersichtlich für die Summe der Artikel an diesem Tag. Wir haben ChatGPT gefragt mit folgendem Prompt: Gibt es ein spezielles Ereignis am 13.06.2023 im Zusammenhang mit der Domain "energy-xprt"?
Antwort: Nach den verfügbaren Informationen gab es am 13. Juni 2023 kein besonderes Ereignis im Zusammenhang mit der Domain "energy-xprt". Energy XPRT ist ein globaler Marktplatz für Lösungen und Anbieter im Energiesektor, der Produktkataloge, Artikel, Branchenveranstaltungen und Publikationen anbietet. citeturn0search0 Obwohl Energy XPRT regelmäßig Veranstaltungen und Neuigkeiten veröffentlicht, scheint an diesem spezifischen Datum kein besonderes Ereignis stattgefunden zu haben.
Wir nehmen dies so zur Kenntnis.
Duplikate beim Artikel?¶
Diese Frage können wir soweit schon beantworten, dass es höchstwahrscheinlich Duplikate gibt, diese aber erst nach der Textbereinigung überprüft werden.
Welches sind die meist benutzten Worte?¶
Um den Datensatz inhaltlich bzw. thematisch noch besser kennen zu lernen, möchten wir sehen, welches die häufigsten Wörter sind. Ob das Bereinigen vor einer solchen Analyse sinnvoll ist, versuchen wir herauszufinden. Deshalb suchen wir nach den häufigsten Wörtern vor und nach der Bereinigung, um so den direkten Vergleich zu erhalten. Wir erstellen zwei Wordclouds.
content = " ".join(df_train["content"].astype(str).tolist())
p.plot_wordcloud(content, c_stopwords=c_stopwords, column_name='content')
titles = " ".join(df_train["title"].astype(str).tolist())
p.plot_wordcloud(titles, c_stopwords=c_stopwords, column_name='title')
Aus diesen beiden Wordclouds kann man erkennen, dass es vorallem Artikle im Energie-Bereich sind.
Sprache überprüfen¶
Prüfen ob alle Artikel einheitliche Sprache haben
def check_language(df: pd.DataFrame, column: str) -> bool:
"""
Prüft, ob alle Texte in einer bestimmten Spalte auf Englisch sind.
Args:
df
column: Name der Spalte mit Text.
Returns:
bool: True, wenn alle Inhalte in der Spalte Englisch sind, sonst False.
"""
try:
all_english = all(
langdetect.detect(text) == "en"
if isinstance(text, str) and text.strip() != "" else False
for text in df[column]
)
if all_english:
print("Alle Inhalte sind auf Englisch.")
else:
print("Die Sprache ist nicht einheitlich Englisch.")
except Exception as e:
print(f"Fehler bei Spracherkennung: {e}")
return False
check_language(df_train, "content")
Die Sprache ist nicht einheitlich Englisch.
# Sprache für jede Zeile erkennen
def detect_language(text: str) -> str:
try:
return detect(text) if isinstance(text, str) and text.strip() != "" else "unknown"
except:
return "error"
# Neue Spalte Spracherkennung
df_train["language"] = df_train["content"].apply(detect_language)
# Sprachen zählen
language_counts = Counter(df_train["language"])
print("Anzahl Artikel pro erkannter Sprache:")
print(language_counts)
Anzahl Artikel pro erkannter Sprache:
Counter({'en': 20106, 'de': 3, 'ru': 1, 'es': 1})
Überprüfen, ob die Sprachzuteilung stimmt. Dazu drucken wir die erste Zeile mit Deutsch aus.
u.print_full_text(df_train[df_train["language"] == 'de'][['id', 'title', 'content', 'language']].head(1), max_width=400)
| id | title | content | language | |
|---|---|---|---|---|
| 2309 | 126129 | SMS group liefert Prozesstechnologie für das erste klimaneutrale Stahlwerk weltweit -- Expo for Decarbonised Industries | ['© SMS group liefert Prozesstechnologie für das klimaneutrale Stahlwerk in Schweden. ( Quelle: SMS group)', 'SMS group, eines der weltweit führenden Unternehmen im metallurgischen Anlagenbau, wurde mit der Lieferung der kompletten Technologie und Ausrüstung für das Projekt H2 Green Steel in Schweden beauftragt. SMS group wird zusammen mit Paul Wurth und deren Konsortialpartner Midrex die gesamte Prozessausrüstung von der Roheisenerzeugung bis hin zu den fertigen Produkten des weltweit ersten industriellen Stahlwerks auf Basis von Wasserstoff und Strom aus erneuerbaren Energien liefern. „ Unser Ziel bei H2 Green Steel ist nichts Geringeres als die industrielle Revolution in der Stahlindustrie anzuführen “, sagte Maria Persson Gulda, CTO von H2 Green Steel. „ Wir setzen auf vorhandene Technologien, modifizieren sie und machen sie innovativ nutzbar, um schon heute grünen Stahl Wirklichkeit werden zu lassen – nicht erst in ferner Zukunft. Wir haben die Anlagen gemeinsam so geplant, dass wir eine bedeutende CO2-Reduzierung über die gesamte Prozesskette erreichen und uns damit von unseren Marktbegleitern differenzieren. Wir haben uns bei diesem Projekt für SMS group entschieden, weil uns ihre Expertise überzeugt hat, die sie in zahlreichen Projekten weltweit unter Beweis gestellt haben. “ „ Wir sind sehr stolz darauf, die Technologie für das erste komplett klimaneutrale Stahlwerk der Welt zu liefern “, sagte Burkhard Dahmen, Vorstandsvorsitzender der SMS group. „ Dies ist nicht nur ein wichtiger Schritt für H2 Green Steel, sondern auch eine ausgezeichnete Gelegenheit, unsere Kompetenz und unsere Mission der grünen Stahlerzeugung zu unterstreichen. “', 'SMS group wird eine Midrex®-Direktreduktionsanlage, ein Elektrostahlwerk, eine CSP® Nexus-Gieß-Walzanlage sowie einen fortschrittlichen Kaltwalz- und Bandanlagen-Komplex für die Produktion eines breiten Produktmixes einschließlich hochfester Stahlgüten ( AHSS) und Stahlgüten für die Automobilindustrie liefern. Führende Automobilhersteller haben bereits mit H2 Green Steel Vereinbarungen über die Lieferung von „ grünem “, hochwertigem Bandstahl unterzeichnet. Das Gesamtauftragsvolumen für SMS group liegt bei über 1 Milliarde Euro.', 'Der Standort für H2 Green Steel wird ein rund 300 Hektar großes Greenfield-Gelände in Boden in der schwedischen Region Norbotten sein. Die Anlage wird voraussichtlich ab 2025 grünen Stahl produzieren und das Produktionsvolumen in 2026 ausbauen.Burkhard Dahmen: „ Grüner Stahl auf Wasserstoffbasis ist die Zukunft der Primärstahlerzeugung. Wir alle arbeiten mit Hochdruck daran, die Schlüsseltechnologien zu liefern, und so ein neues Zeitalter der Stahlerzeugung zu einzuleiten. Wir freuen uns, die Partnerschaft mit dem Team von H2 Green Steel fortzusetzen und dieses revolutionäre Projekt gemeinsam zu verwirklichen. “', 'To use the full function of this web site, JavaScript needs to be enabled in your browser. This is how you enable JavaScript in your browser settings: Read instruction', 'To use the full function of this web site, JavaScript needs to be enabled in your browser.'] | de |
An diesem Beispiel sieht man gut, dass der Titel und der Text Deutsch sind. Einzig die Boilerplates sind in Englisch. Diese werden durch die Textbereinigung entfernt.
Im Trainingsdatensatz wurden 5 von 20111 Artikeln als nicht englisch erkannt. Weil dieser Anteil vernachlässigbar klein ist, wurden diese Artikel bewusst entfernt, da:
- Das RAG-System ausschließlich auf englischsprachigen Daten trainiert wird (sowohl der Retriever als auch der Generator).
- Nicht englische Inhalte potenziell fehlerhafte Embeddings erzeugen könnten, was zu einer schlechteren semantischen Suche oder gar falschen Resultaten führen kann.
- Eine sprachlich homogene Datenbasis sicherstellt, dass alle semantischen Vektoren im gleichen Sprachraum liegen - ein wichtiger Faktor für eine konsistente Performance beim Retrieval.
- Bei größeren Mengen an nicht englischen Daten wäre es hingegen sinnvoll, vor dem Einbetten eine automatische Übersetzung (zB. MarianMT) durchzuführen, um die Datenbasis zu erweitern, ohne sprachliche Inkonsistenzen einzuführen, dazu müsste man zursätzliche Antwort-Postprocessing einführen oder ein multilinguales Modell trainieren.
# Nur englische Artikel behalten
df_train = df_train[df_train["language"] == "en"]
print(f"Anzahl Artikel nach dem Entfernen nicht-englischer Inhalte: {len(df_train)}")
Anzahl Artikel nach dem Entfernen nicht-englischer Inhalte: 20106
Text Bereinigen¶
Da die Daten scheinbar durch Webscraping erstellt wurden, sind einige Sätze in Apostrophe gefasst und mit einem Komma getrennt, daher wird der Text zu einem Fliesstext gemerged.
def fake_list_to_text(text: str) -> str:
if not isinstance(text, str):
return text
if text.count("',") >= 1 and "'" in text:
parts = re.split(r"\s*,\s*", text.strip("[]"))
parts = [p.strip(" '\"\n") for p in parts if p.strip()]
return " ".join(parts)
return text
df_train["content"] = df_train["content"].apply(fake_list_to_text)
df_train.head()
| id | title | date | content | domain | url | language | |
|---|---|---|---|---|---|---|---|
| 0 | 93320 | XPeng Delivered ~100,000 Vehicles In 2021 | 2022-01-02 | Chinese automotive startup XPeng has shown one... | cleantechnica | https://cleantechnica.com/2022/01/02/xpeng-del... | en |
| 1 | 93321 | Green Hydrogen: Drop In Bucket Or Big Splash? | 2022-01-02 | Sinopec has laid plans to build the largest gr... | cleantechnica | https://cleantechnica.com/2022/01/02/its-a-gre... | en |
| 2 | 98159 | World’ s largest floating PV plant goes online... | 2022-01-03 | Huaneng Power International has switched on a ... | pv-magazine | https://www.pv-magazine.com/2022/01/03/worlds-... | en |
| 3 | 98158 | Iran wants to deploy 10 GW of renewables over ... | 2022-01-03 | According to the Iranian authorities there are... | pv-magazine | https://www.pv-magazine.com/2022/01/03/iran-wa... | en |
| 4 | 31128 | Eastern Interconnection Power Grid Said ‘ Bein... | 2022-01-03 | Sign in to get the best natural gas news and d... | naturalgasintel | https://www.naturalgasintel.com/eastern-interc... | en |
Klasse TextCleaner¶
Für die Text Bereinigung haben wir eine Klasse TextCleaner erstellt.
Die Klasse TextCleaner ist dafür gedacht, Webtexte oder Textdaten von sogenannter „Boilerplate“ zu bereinigen – das sind Textteile, die keinen inhaltlichen Mehrwert liefern, wie z. B. Cookie-Hinweise, rechtliche Hinweise oder Login-Formulare. Solche Texte stören oft bei der Analyse von Webinhalten, NLP-Projekten oder Textklassifikation. Schauen wir uns die Klasse im Detail an:
init: Konstruktor Hier werden zwei Dinge initialisiert:
boilerplate_patterns: Eine Liste an regulären Ausdrücken (regex), um häufig vorkommende, irrelevante Textbestandteile zu erkennen und zu entfernen (z. B. Cookie-Banner, Captcha, rechtliche Hinweise, Navigation, Newsletter-Aufrufe etc.).
end_markers: Stichworte, bei denen davon ausgegangen wird, dass ab diesem Punkt der Text irrelevant ist und abgeschnitten werden kann.
truncate_boilerplate_tail(text)
Schneidet den Text an dem Punkt ab, an dem einer der end_markers auftaucht (z. B. „this content is protected“). Das hilft, um am Ende des Textes automatisch irrelevante Abschnitte zu entfernen.
clean_text(text)
Dies ist die zentrale Methode zur Textbereinigung. Sie macht folgendes:
Entfernt URLs mit einem regex.
Vereinheitlicht typographische Zeichen (z. B. ersetzt typographische Anführungszeichen durch Standardzeichen).
Wendet alle boilerplate_patterns auf den Text an und entfernt sie.
Ersetzt Sonderzeichen wie Bindestriche und Unterstriche durch Leerzeichen.
Entfernt alle Zeichen außer Buchstaben, Zahlen, Satzzeichen und deutsche Umlaute.
Schneidet am Ende des Textes alles ab, was nach einem end_marker kommt (via truncate_boilerplate_tail).
Gibt den bereinigten Text zurück.
is_meaningful(text)
Prüft, ob der Text nach der Bereinigung überhaupt noch sinnvollen Inhalt hat:
Ist nicht leer (enthält Buchstaben oder Zahlen).
Ist nicht nur „Meta-Text“, wie z. B. „NGI“ oder eine ISSN.
So können irrelevante oder leere Texte leicht erkannt und ggf. verworfen werden.
clean_text_column(df, column, new_column=None)
Diese Methode ist gedacht für Pandas DataFrames:
Wendet clean_text() auf eine ganze Spalte (column) an.
Schreibt die bereinigten Texte entweder in dieselbe oder in eine neue Spalte (new_column).
Filtert alle Zeilen raus, deren bereinigter Text nicht sinnvoll ist (is_meaningful).
Um die Funktion des TextCleaners zu überprüfen, verwenden wir den Datenstatz article_count_per_title, da dieser die vermuteten doppelten Inhalte aufzeigen kann.
cleaner = TextCleaner(level="risky")
data_cleaned = cleaner.clean_text_column(article_count_per_title, column="content", new_column="content_cleaned")
data_cleaned_compare = data_cleaned[["content", "content_cleaned"]].copy()
u.styled_text(data_cleaned_compare.head(), max_width=500)
| content | content_cleaned | |
|---|---|---|
| 1721 | ['We use cookies to enhance your experience. By co ntinuing to browse this site you agree to our use of cookies. More info.', 'B.A ( Hons) Comparative Literary Studies, M.A. Modern Cultures', 'David is an academic researcher and interdisciplinary arti ... | '. More info.', 'B.A Hons Comparative Literary St udies, M.A. Modern Cultures', 'David is an academi c researcher and interdisciplinary artist primaril y working with text, video, sound, and new technol ogies. His current research and practice is focuse ... |
| 6940 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | "By clicking Allow All '' you agree to the storin g of cookies on your device to enhance site naviga tion, analyse site usage and support us in providi ng free open access scientific content. More info. ", 'B.A Hons Comparative Literary Studies, M.A. M ... |
| 6941 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | "By clicking Allow All '' you agree to the storin g of cookies on your device to enhance site naviga tion, analyse site usage and support us in providi ng free open access scientific content. More info. ", 'B.A Hons Comparative Literary Studies, M.A. M ... |
| 6942 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | "By clicking Allow All '' you agree to the storin g of cookies on your device to enhance site naviga tion, analyse site usage and support us in providi ng free open access scientific content. More info. ", 'B.A Hons Comparative Literary Studies, M.A. M ... |
| 7107 | ["By clicking `` Allow All '' you agree to the sto ring of cookies on your device to enhance site nav igation, analyse site usage and support us in prov iding free open access scientific content. More in fo.", 'B.A ( Hons) Comparative Literary Studies, M ... | "By clicking Allow All '' you agree to the storin g of cookies on your device to enhance site naviga tion, analyse site usage and support us in providi ng free open access scientific content. More info. ", 'B.A Hons Comparative Literary Studies, M.A. M ... |
Nun ist gut zu erkennen, dass es sich höchstwahrscheinlich um dieselben Texte handelt, zumindest sind die ersten 5 Zeilen identisch. Diese Erkenntnis werden wir nutzen, um Duplikate zu entfernen.
Duplikate entfernen¶
Bevor die Duplikate entfernt werden können, muss der gesamte Text mit dem TextCleaner bereinigt werden.
Titel und Inhalt-Längen¶
Wir wollen sehen, ob es sehr lange Titel oder sehr kurze Inhalte gibt. Dazu schauen wir uns die Textlängen an. Dies machen wir vor und nach dem Text Bereinigen.
Gesamten Text bereinigen¶
df_train_cleaned = cleaner.clean_text_column(df_train, column="content", new_column="content_cleaned")
u.styled_text(df_train_cleaned.head(3))
| id | title | date | content | domain | url | language | content_cleaned | |
|---|---|---|---|---|---|---|---|---|
| 0 | 93320 | XPeng Delivered ~100,000 Vehicles In 2021 | 2022-01-02 00:00:00 | Chinese automotive startup XPeng has shown one of the most dramatic auto production ramp-ups in hist ory and the good news is it only produces 100% sma rt electric vehicles ( EVs). At a mere 7 years of age and just a few years after launching its first ... | cleantechnica | https://cleantechnica.com/2022/01/02/xpeng-deliver ed-100000-vehicles-in-2021/ | en | Chinese automotive startup XPeng has shown one of the most dramatic auto production ramp ups in hist ory and the good news is it only produces 100 smar t electric vehicles EVs. At a mere 7 years of age and just a few years after launching its first ve ... |
| 1 | 93321 | Green Hydrogen: Drop In Bucket Or Big Splash? | 2022-01-02 00:00:00 | Sinopec has laid plans to build the largest green hydrogen production facility in the world but inte rest in fossil-sourced hydrogen continues apace. S kepticism abounds over the green hydrogen field an d yet leading players on the global energy stage s ... | cleantechnica | https://cleantechnica.com/2022/01/02/its-a-green-h ydrogen-drop-in-the-bucket-but-it-could-still-make -a-splash/ | en | Sinopec has laid plans to build the largest green hydrogen production facility in the world but inte rest in fossil sourced hydrogen continues apace. S kepticism abounds over the green hydrogen field an d yet leading players on the global energy stage s ... |
| 2 | 98159 | World’ s largest floating PV plant goes online in China – pv magazine International | 2022-01-03 00:00:00 | Huaneng Power International has switched on a 320 MW floating PV array in China’ s Shandong province . It deployed the plant in two phases on a reservo ir near its 2.65 GW Dezhou thermal power station. Huaneng Power International ( HPI) has completed t ... | pv-magazine | https://www.pv-magazine.com/2022/01/03/worlds-larg est-floating-pv-plant-goes-online-in-china/ | en | Huaneng Power International has switched on a 320 MW floating PV array in China' s Shandong province . It deployed the plant in two phases on a reservo ir near its 2.65 GW Dezhou thermal power station. Huaneng Power International HPI has completed the ... |
u.styled_text(df_train_cleaned.describe(include=[object]))
| title | content | domain | url | language | content_cleaned | |
|---|---|---|---|---|---|---|
| count | 20106 | 20106 | 20106 | 20106 | 20106 | 20106 |
| unique | 20011 | 20063 | 25 | 20106 | 1 | 19988 |
| top | About David J. Cross | By the end of 2022 37% of single-family homes acro ss the five islands Hawaiian Electric serves had r ooftop solar Oahu's first grid-scale solar and sto rage project was online and the state's last remai ning coal plant was retired. That's the kind of pr ... | energy-xprt | https://cleantechnica.com/2022/01/02/xpeng-deliver ed-100000-vehicles-in-2021/ | en | Energy Human development Solar Energy Wind Power 01 20 September 2014 Paderborn Germany. The scie ntific engineering program focus on solar energy w ind power human development and energy transition as well as lectures on the basic of renewable ene ... |
| freq | 13 | 3 | 4181 | 1 | 20106 | 10 |
Duplikate werden auf die Spalte'content_cleaned' überprüft. Falls es Duplikate hat, wir der Datensatz, welcher vom Datum her der aktuellste ist, behalten.
def drop_duplicates_keep_latest(df: pd.DataFrame) -> pd.DataFrame:
"""
Entfernt Duplikate basierend auf den Spalten 'title', 'content_cleaned', 'domain', und 'url' und behält den neuesten Eintrag.
"""
df['date'] = pd.to_datetime(df['date'], errors='coerce')
df = df.sort_values('date').drop_duplicates(subset=['content_cleaned'], keep='last')
return df
df_train_cleaned_unique = df_train_cleaned.copy(deep=True)
df_train_cleaned_unique = drop_duplicates_keep_latest(df_train_cleaned_unique)
len(df_train_cleaned), len(df_train_cleaned_unique), len(df_train_cleaned) - len(df_train_cleaned_unique)
(20106, 19988, 118)
Kontrolle, ob nicht Datensätze gelöscht wurden, welche für die Evaluation nötig sind.
def check_target_url_in_train_df(target_df: pd.DataFrame, train_df: pd.DataFrame) -> pd.DataFrame:
url_in_train_df = set(train_df['url'])
target_df['url_in_train_df'] = target_df['article_url'].isin(url_in_train_df)
return target_df
# read parquet file
cleantech_rag_evaluation_data = pd.read_parquet('../data_mc1/data_processed/cleantech_rag_evaluation_data.parquet')
url_check = check_target_url_in_train_df(cleantech_rag_evaluation_data, df_train_cleaned_unique)
print(f"Es fehlen {len(url_check[url_check['url_in_train_df'] == False])} Datensätze, welch durch die Bereinigung gelöscht wurden und im Evaluationsdatensatz enthalten sind.")
Es fehlen 0 Datensätze, welch durch die Bereinigung gelöscht wurden und im Evaluationsdatensatz enthalten sind.
print(f"Nach dem Bereinigen sind noch {len(df_train_cleaned_unique)} Artikel übrig (von ursprünglich {len(df_train)}), was einer Reduktion von {len(df_train) - len(df_train_cleaned_unique)} Artikeln entspricht.")
df_train_cleaned = df_train_cleaned_unique.copy(deep=True)
Nach dem Bereinigen sind noch 19988 Artikel übrig (von ursprünglich 20106), was einer Reduktion von 118 Artikeln entspricht.
Wordcloud 2.0¶
Nach der erfolgreichen Bereinigung erstellen wir nochmals dieselben Wordclouds wie zuvor.
content = " ".join(df_train_cleaned["content_cleaned"].astype(str).tolist())
p.plot_wordcloud(content, c_stopwords=c_stopwords, column_name='content_cleaned')
titles = " ".join(df_train_cleaned["title"].astype(str).tolist())
p.plot_wordcloud(titles, c_stopwords=c_stopwords, column_name='title')
Im Vergleich zu den nicht bereinigten Wordclouds kann man nun einen deutlichen Unterschied zwischen Titel und Inhalt erkennen. Vorher war beides sehr ähnlich. Wenn man die Wordcloud vom Content anschaut, könnte man zum Schluss kommen, dass der Inhalt noch weiter Bereinigt werden sollte, da es nun einige Stopwords anzeigt. Dass bei der zweiten Wordcloud aus Title einzelne Buchstaben angezeigt werden, lässt ebenfalls darauf schliessen, dass noch weiter bereinigt werden sollte. Zuerst möchten wir aber die wichtigen Wörter mit TF-IDF anschauen und danach beurteilen, wie weiter bereinigt werden sollte.
Spalte content droppen und contetent_cleaned zu content umbenennen
df_train_cleaned = df_train_cleaned.drop(columns=["content"])
df_train_cleaned = df_train_cleaned.rename(columns={"content_cleaned": "content"})
Titel an den Content anfügen¶
Der Titel wird jeweils zu Beginn des Contents getrennt mit einem Doppelpunkt hinzugefügt. Damit muss nur noch der Content embedded werden.
# ermittle die maximale Länge der Titel
max_title_length = df_train_cleaned['title'].str.len().max()
print(f"Maximale Länge der Titel: {max_title_length}")
# ermittle die minimale Länge der Inhalte
min_content_length = df_train_cleaned['content'].str.len().min()
print(f"Minimale Länge der Inhalte: {min_content_length}")
# ermittle, welche Titel länger sind als ihre Inhalte
longer_titles = df_train_cleaned[df_train_cleaned['title'].str.len() > df_train_cleaned['content'].str.len()]
print(f"Anzahl Titel, die länger sind als ihre Inhalte: {len(longer_titles)}")
Maximale Länge der Titel: 403 Minimale Länge der Inhalte: 8 Anzahl Titel, die länger sind als ihre Inhalte: 36
# Kontrolliere, ob die evaluationadaten (urls) in den longer_titles enthalten sind
print(f"Anzahl Evaluationsdaten, die in den longer_titles enthalten sind: {len(longer_titles[longer_titles['url'].isin(cleantech_rag_evaluation_data['article_url'])])}")
Anzahl Evaluationsdaten, die in den longer_titles enthalten sind: 0
# Lösche die Datensätze von longer_titles aus dem df_train_cleaned
df_train_cleaned = df_train_cleaned[~df_train_cleaned['id'].isin(longer_titles['id'])]
# Title und Content zusammenführen
df_train_cleaned['text'] = df_train_cleaned['title'] + ": " + df_train_cleaned['content']
df_train_cleaned.head(3)
| id | title | date | domain | url | language | content | text | |
|---|---|---|---|---|---|---|---|---|
| 0 | 93320 | XPeng Delivered ~100,000 Vehicles In 2021 | 2022-01-02 | cleantechnica | https://cleantechnica.com/2022/01/02/xpeng-del... | en | Chinese automotive startup XPeng has shown one... | XPeng Delivered ~100,000 Vehicles In 2021: Chi... |
| 1 | 93321 | Green Hydrogen: Drop In Bucket Or Big Splash? | 2022-01-02 | cleantechnica | https://cleantechnica.com/2022/01/02/its-a-gre... | en | Sinopec has laid plans to build the largest gr... | Green Hydrogen: Drop In Bucket Or Big Splash?:... |
| 13 | 65564 | Community solar policy gets green light in man... | 2022-01-03 | solarpowerworldonline | https://www.solarpowerworldonline.com/2022/01/... | en | Community solar is a unique market segment tha... | Community solar policy gets green light in man... |
df_train_cleaned = df_train_cleaned.drop(columns=["content"])
df_train_cleaned = df_train_cleaned.rename(columns={"text": "content"})
Datensatz mit 1000 Zeilen¶
Um die Ressourcen nicht zu schnell zu verbrauchen, reduzieren wir den Datensatz auf 1000 Zeilen. Dabei wird darauf geachtete, dass alle Zeilen, die im Testdatensatz vorhanden sind, auch im reduzierten Datensatz sind. Das Vorgehen ist folgendermassen: alle Daten, die für die Tests benötigt werden
df_train_cleaned_subset = df_train_cleaned[df_train_cleaned['url'].isin(cleantech_rag_evaluation_data['article_url'])].copy(deep=True)
df_train_subset_1000 = df_train_cleaned.sample(n=1000-len(df_train_cleaned_subset), random_state=42, replace=False)
df_train_1000 =pd.concat([df_train_cleaned_subset, df_train_subset_1000], ignore_index=True)
Chunking¶
Beim Chunking werden die Token zu bedeutungsvolleren Einheiten zusammengefasst, wie zB. Sätze oder thematischen Einheiten (je nach Bedarf).
Ein Overlap (Überlappung) zwischen Chunks wird verwendet, um den semantischen Zusammenhang zu erhalten.
zB.:
Chunk 1: "Das Unternehmen Tesla hat eine neue Batterie entwickelt."
Chunk 2: "Sie hält 50% länger als bisherige Modelle."
-> Chunk 2 hätte keinen Bezug zum Unternehmen "Tesla" ohne einen Teil aus Chunk 1. -> der Kontext soll also erhalten bleiben.
Tokenisierung¶
Tokenisierung zerlegt den Text in kleine Einheiten (Zeichen, Wörter).
Tokensierung wird automatisch durch das Embedding-Modell übernommen.
Embeddings¶
Für das Embedding mit LangChain: Keine Kleinschreibung erzwingen (Grossbuchstaben sind wichtig für Satzgrenzen und Entitätenerkennung)
Jeder Chunk wird in einen numerischen Vektor umgewandelt. Diese Vektoren repräsentieren die Bedeutung des Textes. Chunks mit ähnlicher Bedeutung haben ähnliche Vektoren
In dem Python-Skript Chroma_Embedding_Pipeline.py ist die Pipeline für die Erstellung der Embeddings und deren Speicherung in Chroma implementiert. In dem archiv/testing_embedding.ipynb wurden einzelne Schritte getestet und basierend auf den Ergebnissen die Pipeline erstellt.
Chroma Daten¶
Die verschiedenen Chroma Datenbänke werden in dem Notebook chroma_data.ipynb erstellt und lokal gespeichert, da sie für GitLab zu gross sind. Hier wurden ebenfalls einige tests in dem Notebook archiv/testing_embedding.ipynb gemacht, um die Chroma DB zu testen.
Übersicht der Konfigurationen¶
| DB-Name | TextSplitter | Chunk Size / Overlap | Ähnlichkeitsmetrik | Erwartete Auswirkungen |
|---|---|---|---|---|
recchar_800_cosine |
RecursiveCharacterTextSplitter |
800 Zeichen / 100 | Cosine | Gute Balance zwischen Genauigkeit und Effizienz; geringer Ressourcenverbrauch. |
recchar_800_l2 |
RecursiveCharacterTextSplitter |
800 Zeichen / 100 | L2 (Euklidisch) | Potenziell bessere Treffergenauigkeit; höherer Rechen- und Speicherbedarf. |
recchar_800_ip |
RecursiveCharacterTextSplitter |
800 Zeichen / 100 | IP (Inneres Produkt) | Abhängig vom Textinhalt; bei passenden Daten eventuell bessere Relevanz. |
senttrans_200_cosine |
SentenceTransformersTokenTextSplitter |
200 Token / 20 | Cosine | Höhere Präzision bei modernen Modellen; Chunkgrenzen wirken teils unnatürlich. |
senttrans_200_l2 |
SentenceTransformersTokenTextSplitter |
200 Token / 20 | L2 (Euklidisch) | Sehr genaue Ergebnisse möglich; deutlich erhöhter Ressourcenbedarf. |
senttrans_200_ip |
SentenceTransformersTokenTextSplitter |
200 Token / 20 | IP (Inneres Produkt) | Uneinheitliche Resultate; sinnvoll bei bestimmten Textarten oder Spezialanwendungen. |
Detaillierte Parameterbeschreibung¶
Jedes der sechs Konfigurationen wurde ebenfalls mit einem zusätzlichen Embedding-Modell getestet, um
1. Embedding-Modell¶
Jede Konfiguration wird mit zwei verschiedenen Embedding-Modellen getestet, um die Auswirkungen der Modellwahl auf die Qualität der Embeddings und die Effizienz des Retrievals zu evaluieren.
text-embedding-3-large
- Beschreibung: Hochperformantes Embedding-Modell der dritten Generation von OpenAI mit stark verbesserter semantischer Repräsentationsfähigkeit.
- Vorteile: Sehr hohe Genauigkeit bei der semantischen Suche, besonders geeignet für komplexe, nuancenreiche Inhalte.
- Nachteile: Höherer Ressourcenverbrauch (Rechenleistung & Kosten) im Vergleich zu kleineren Modellen.
- Erwartung: Führt zu einer signifikanten Verbesserung der Suchqualität, insbesondere in Kombination mit präzisen TextSplittern und anspruchsvollen Metriken.
text-embedding-ada-002
- Beschreibung: Kosteneffizientes und schnelles Embedding-Modell der zweiten Generation mit solider semantischer Qualität.
- Vorteile: Günstig, schnell und für viele Standardanwendungen ausreichend präzise.
- Nachteile: Geringere semantische Tiefe und Genauigkeit im Vergleich zu größeren Modellen.
- Erwartung: Gute Baseline-Performance für einfache bis mittelschwere Anwendungsfälle mit niedrigem Ressourcenbedarf.
2. TextSplitter¶
Die Wahl des TextSplitters bestimmt maßgeblich die Granularität der Chunks und beeinflusst damit die Qualität der Embeddings sowie die Suchpräzision.
RecursiveCharacterTextSplitter (
chunk_size=800,chunk_overlap=100,separators=["\n\n", "\n", ".", " ", ""])- Beschreibung: Hierarchische Aufteilung entlang natürlicher Textgrenzen wie Absätze, Sätze und Wörter.
- Vorteile: Semantisch kohärente Chunks, geringer Rechenaufwand, einfache Implementierung.
- Nachteile: Ignoriert Token-Grenzen von Transformer-Modellen, was Embedding-Effizienz beeinträchtigen kann.
- Erwartung: Sehr gute Performance bei strukturierten Texten wie Berichten und Artikeln.
SentenceTransformersTokenTextSplitter (
chunk_size=200 Tokens,chunk_overlap=20,model_name="sentence-transformers/all-MiniLM-L6-v2")- Beschreibung: Aufteilung auf Basis der Tokenisierung eines Transformer-Modells.
- Vorteile: Bessere Anpassung an Embedding-Modelle, präzisere Repräsentation komplexer Inhalte.
- Nachteile: Chunks können mitten in Sätzen enden; erhöhter Rechenaufwand durch Tokenisierung.
- Erwartung: Höhere Präzision bei technischen oder informationsdichten Texten.
3. Ähnlichkeitsmetriken (hnsw:space)¶
Die Metrik definiert, wie Ähnlichkeit zwischen Vektoren gemessen wird und beeinflusst somit die Qualität und Reihenfolge der Treffer.
Cosine (Cosinus-Ähnlichkeit):
- Beschreibung: Vergleicht die Richtung von Vektoren, robust gegenüber Skalierungsunterschieden.
- Vorteile: Schnelle Berechnung, speichereffizient, bewährter Standard für Text-Embeddings.
- Nachteile: Kann bei sehr ähnlichen Einträgen unpräziser sein.
- Erwartung: Solide Basislinie mit guter Balance zwischen Qualität und Performance.
L2 (Euklidische Distanz):
- Beschreibung: Misst den tatsächlichen Abstand zwischen Vektoren im Raum.
- Vorteile: Höhere Genauigkeit bei fein abgestuften Ähnlichkeiten.
- Nachteile: Deutlich rechenintensiver und speicheraufwändiger.
- Erwartung: Präzisere Resultate bei komplexen, feingranularen Abfragen.
IP (Inneres Produkt):
- Beschreibung: Fokus auf die Projektion von Vektoren zueinander, weniger auf den absoluten Abstand.
- Vorteile: Kann bei normalisierten Embeddings Vorteile bieten.
- Nachteile: Ergebnisse sind schwerer vorhersehbar; kann unzuverlässig bei allgemeinen Texten sein.
- Erwartung: Starke Abhängigkeit vom spezifischen Embedding- und Anwendungsfall.
4. Konstant gehaltene Parameter¶
Um die Auswirkungen von Splitter- und Metrikvarianten isoliert evaluieren zu können, bleiben folgende Werte konstant:
- HNSW-Parameter:
hnsw:M=16,efConstruction=200- Begründung: Standardkonfiguration für eine ausgewogene Balance zwischen Genauigkeit und Speicherverbrauch.
- Indexierungspipeline:
batch_size=20,sleep_time=1.0- Begründung: Verhindert API-Überlastung durch konservative Anfragefrequenz, sorgt für Stabilität während des Ladens.
Fazit¶
Diese sechs Konfigurationen ermöglichen eine strukturierte Evaluierung der Auswirkungen unterschiedlicher Text-Splitting-Strategien und Ähnlichkeitsmetriken, welche mithilfe von RAGAS evaluiert und verglichen werden.
Retrieval-Modul (Suche & Ranking) & Generator-Modul (Antwortgenerierung)¶
Ablauf der RetrievalQA-Evaluations-Chain¶
- Retriever: Holt relevante Dokumente basierend auf der Frage (
retriever.invoke). - Retrieved Texts: Extrahiert nur die Inhalte (
page_content) der Dokumente. - Context: Verbindet die Inhalte zu einem großen Textblock (
\n\n.join(...)). - Prompt Template: Fügt den generierten Context und die Frage in ein definiertes Prompt-Template ein.
- LLM Call: Ruft das LLM auf, um auf Basis von Context + Frage eine Antwort zu erzeugen.
- Speicherung: Frage, Antwort, verwendete Texte und Context werden für die spätere Evaluation gespeichert.
Reihenfolge ist essenziell:
Retriever → Texte → Context → Prompt → LLM
Varianten im Retrieval¶
Es wurden verschiedene Konfigurationen des Retrievals getestet, um den Einfluss auf die Antwortqualität zu analysieren:
Similarity Retrieval (Top-k Suche):
- similarity_k3: Holt die 3 ähnlichsten Chunks zum Query.
- similarity_k5: Holt die 5 ähnlichsten Chunks zum Query.
Beim Similarity Retrieval werden die Chunks basierend auf der Ähnlichkeit (meist gemessen als Distanz im Vektorraum) zum Query sortiert und die Top-k ähnlichsten Chunks ausgewählt. Der Parameter k bestimmt dabei, wie viele Chunks pro Anfrage abgerufen werden.
Maximal Marginal Relevance (MMR Retrieval):
- mmr_k5_fetch20: Wählt 5 diverse Chunks aus 20 vorselektierten Kandidaten.
- mmr_k7_fetch20: Wählt 7 diverse Chunks aus 20 vorselektierten Kandidaten.
Beim MMR Retrieval wird nicht nur die Ähnlichkeit zum Query berücksichtigt, sondern zusätzlich die Diversität unter den ausgewählten Chunks maximiert. Hier steuert der Parameter fetch_k, wie viele Kandidaten zunächst auf Basis der Ähnlichkeit vorgeladen werden, und k, wie viele davon dann nach maximaler Diversität ausgewählt werden.
Weitere Parameter:¶
Temperatur:
Die Temperatur des LLMs wurde standardmäßig auf 0.5 gesetzt, kann jedoch im System flexibel angepasst werden, da sie als einstellbarer Parameter übergeben wird.
Die Temperatur steuert die Glättung oder Schärfung der Wahrscheinlichkeitsverteilung über die möglichen nächsten Token im Sprachmodell.
- Eine niedrige Temperatur (z.B. 0.2) führt zu deterministischeren, präziseren Antworten und bewirkt eine Schärfung der Verteilung:
Wahrscheinlichkeiten mit ohnehin hohem Wert werden noch dominanter. Das Modell bevorzugt sehr wahrscheinliche Token. - Eine höhere Temperatur (z.B. 0.7) erzeugt kreativere, vielfältigere Antworten mit mehr Variabilität und glättet die Verteilung:
Unterschiede zwischen den Token-Wahrscheinlichkeiten werden abgeschwächt, wodurch auch weniger wahrscheinliche Token eher ausgewählt werden können.
Einfluss auf die RAGAS-Evaluierung - Unterschiedliche Temperaturen können direkte Auswirkungen auf die RAGAS-Metriken haben:
Niedrige Temperaturen verbessern tendenziell die Faithfulness- und Context Relevance-Scores, da die Antworten näher am bereitgestellten Kontext bleiben.
Hohe Temperaturen können zu kreativ ausgeschmückten Antworten führen, die zwar sprachlich korrekt erscheinen, aber weniger genau auf dem tatsächlichen Kontext basieren, was die Groundedness und Relevanz-Bewertungen negativ beeinflussen kann.
In dieser Evaluation lag der Fokus auf kontrollierten und replizierbaren Antworten, weshalb moderate Temperaturen verwendet wurden.
Prompting-Strategien:
Alle Varianten wurden systematisch mit zwei verschiedenen Prompt-Templates getestet und die Ergebnisse gespeichert:
- Simple Prompt: Der LLM wird angewiesen, die Frage basierend auf dem bereitgestellten Kontext direkt zu beantworten und bei Unsicherheit offen "I do not know" anzugeben.
- Chain-of-Thought Prompt: Der LLM wird aufgefordert, vor der finalen Antwort eine schrittweise Überlegung ("Chain of Thought") zu formulieren, um so die Qualität und Nachvollziehbarkeit der Antworten zu erhöhen.
Hinweis:
Die Prompting-Strategien wurden bewusst nicht exzessiv optimiert oder angepasst, da die Qualität der Antworten auch stark von der Formulierung der Benutzerfragen abhängt.
Eine umfassende Optimierung des Promptings wäre zudem sehr zeitintensiv und wurde aufgrund der Projektziele nicht priorisiert.
Auf weitere Varianten von top-k, fetch_k, anderen Retrieval-Methoden und umfangreichere Prompting-Experimente wurde aus zeitlichen Gründen verzichtet.
Output:¶
- question: Frage aus dem Eval-Set
- relevant_text: "Ground Truth" aus dem Eval-Set
- relevant_text_llm: Liste der Top-K retrieved Chunks
- retrieved_context: Der Kontext-String, den das LLM tatsächlich gesehen hat
- answer: Erwartete Antwort aus Eval-Set
- answer_llm: Antwort, die das Modell produziert
Evaluator-Modul (Qualitätsprüfung & Optimierung)¶
Im Rahmen dieser Arbeit wurde eine extrinsische Evaluation des RAG-Systems mithilfe des Frameworks RAGAS durchgeführt. Dabei kamen sowohl LLM-basierte Qualitätsmetriken als auch klassische Information-Retrieval-Metriken zum Einsatz. Ziel war eine umfassende Bewertung der Systemleistung über verschiedene Dimensionen hinweg. Die wichtigsten Erkenntnisse sind in den dargestellten Boxplots und Balkendiagrammen visualisiert.
In dem Python-Skript evaluation.py ist die Pipeline für die automatische Evualierung per RAGAS und non-LLM metriken, sowie deren Visualisierung. Die Ergebnisse werden ausserdem in data_mc1/data_evaluierung abgelegt um nachträglich für weiter Analysen darauf zugreifen zu können.
Übersicht evaluation.py:
- Lädt Chroma-Collection mit Embeddings
- Unterstützt Retriever-Typen
- Prompting & Chain-Erstellung (simple, cot)
- Erstellt LangChain-Pipeline (Retriever → Prompt → LLM)
- Antwortgenerierung: speichert Antwort, Kontext, Gold-Referenz
- Evaluation: RAGAS- und IR-Metriken
- Visualisierung der Ergebnisse (Boxplot & Balken)
Konfigurierbare Komponenten
- Retriever: similarity_k3, similarity_k5, mmr_k5, mmr_k7
- Prompting: simple, chain_of_thought
- Temperatur: variable
- Embeddings: text-embedding-3-large oder text-einbettung-ada-002 via Azure OpenAI
- LLM Modelle: Antwortgenerierung mit gpt-4o-mini via Azure OpenAI
Evaluierte Metriken¶
LLM-basierte Metriken (RAGAS)
Diese Metriken werden automatisch durch ein LLM (gpt-4o-mini) bewertet und basieren auf der Qualität der generierten Antwort im Verhältnis zum abgerufenen Kontext:
Faithfulness: Bewertet, ob die generierte Antwort sachlich korrekt und durch den bereitgestellten Kontext belegbar ist.
→ Ein hoher Wert nahe 1 zeigt, dass die Antwort inhaltlich treu und gut gestützt ist.Answer Relevance: Misst, ob die generierte Antwort überhaupt zur gestellten Frage passt.
→ Ein hoher Wert nahe 1 ist wünschenswert - Werte nahe 0 deuten auf irrelevante oder fehlgeleitete Antworten hin. (Verbesserungspotenzial bei Promptgestaltung oder Retrieval-Qualität)Context Precision: Gibt an, wie viel Prozent des verwendeten Kontexts tatsächlich relevant zur Frage ist.
→ Hohe Präzision nahe 1 bedeutet, dass kaum irrelevante Information im Kontext enthalten ist - ein Indikator für effizientes Retrieval.Context Recall: Bewertet, ob alle für die Antwort relevanten Informationen im Kontext enthalten sind.
→ Ein hoher Wert nahe 1 zeigt, dass der Kontext vollständig genug war, um die Frage zu beantworten.Answer Correctness: Überprüft, ob die Antwort nicht nur relevant, sondern auch objektiv korrekt ist.
→ Ein hoher Wert nahe 1 bedeutet korrekte Antworten; Schwankungen hier weisen auf Unsicherheiten in der LLM-Generierung hin.
Nicht-LLM-basierte klassische IR-Metriken
Diese Metriken basieren auf der Analyse der Treffergenauigkeit beim Retrieval und sind unabhängig von der Antwortgenerierung. Auch hier gilt: Werte nahe 1 sind besser.
- Precision@k: Anteil der tatsächlich relevanten Chunks unter den Top-k Retrievals
- Recall@k: Gibt an ob der relevante Chunk in den Top-k enthalten ist - Fokus auf Vollständigkeit. Dies ist besonders wichtig für Systeme mit geringer Fehlertoleranz.
- MRR (Mean Reciprocal Rank): Misst, an welcher Position der erste relevante Treffer erscheint. Ein Wert nahe 1 bedeutet, dass der relevante Chunk meist sehr weit oben in der Liste erscheint.
Durchführung des Experiments¶
Die Evaluation des RAG-Systems erfolgte in mehreren aufeinander aufbauenden Schritten, um systematisch die optimale Konfiguration zu identifizieren und Ressourcen zu sparen:
Embedding-Modelle (12 Varianten) Zunächst wurden zwölf unterschiedliche Embedding-Varianten getestet. Ziel war es, jene Variante zu finden, die die besten Resultate im Hinblick auf Retrieval-Qualität und LLM-Auswertung liefert. Das leistungsstärkste Modell wurde für die weiteren Schritte übernommen.
Retriever- und Prompt-Kombinationen Mit dem "besten" Embedding-Modell wurden sämtliche Kombinationen aus verschiedenen Retrieval-Strategien (z. B. Similarity, MMR) und Prompting-Methoden (z. B. „simple“, „chain of thought“) evaluiert. Auch hier wurde die beste Kombination für den nächsten Schritt selektiert.
Temperatur-Variationen (5 Stufen) Abschließend wurden fünf unterschiedliche Sampling-Temperaturen getestet, um den Einfluss auf Antwortdiversität und Qualität zu untersuchen.
Evaluierung Embeddings¶
Um die verschiedenen Embedding-Modelle isoliert vergleichen zu können, wurden alle übrigen Parameter konstant gehalten. Dazu zählten insbesondere der Retriever-Typ (k=5, Similarity), die Prompting-Strategie (simple) sowie die Temperatur bei der Antwortgenerierung.
Ein gutes Embedding zeigt sich vor allem durch hohe Werte bei Recall@5, Context Recall, Answer Correctness und Similarity to Gold, da diese Metriken direkt davon abhängen, wie gut relevante Informationen im Vektorraum repräsentiert und wiedergefunden werden.
RecursiveCharacterTextSplitter, Cosine Similarity, Embedding 3 large
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_cosine_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="800_cosine_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:15<00:00, 1.25it/s]
Durchschnittliche Antwortähnlichkeit: 0.8089461937183137
RecursiveCharacterTextSplitter, Cosine Similarity, Embedding ada 002
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_cosine_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_800_cosine_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:15<00:00, 1.26it/s]
Durchschnittliche Antwortähnlichkeit: 0.9224537753013365
RecursiveCharacterTextSplitter, IP Similarity, Embedding 3 large
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_ip_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="800_ip_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:20<00:00, 1.18it/s]
Durchschnittliche Antwortähnlichkeit: 0.7402009444554254
RecursiveCharacterTextSplitter, IP Similarity, Embedding 3 large
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_800_ip_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:18<00:00, 1.21it/s]
Durchschnittliche Antwortähnlichkeit: 0.9300966413118155
RecursiveCharacterTextSplitter, l2 Similarity, Embedding 3 large
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_l2_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="800_l2_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:19<00:00, 1.20it/s]
Durchschnittliche Antwortähnlichkeit: 0.7679850248820453
RecursiveCharacterTextSplitter, l2 Similarity, Embedding ada 002
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_recchar_800_l2_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_800_l2_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:23<00:00, 1.13it/s]
Durchschnittliche Antwortähnlichkeit: 0.9318871484441911
SentenceTransformersTokenTextSplitter, Cosine Similarity, Embedding 3 large
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_cosine_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="200_cosine_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:27<00:00, 1.08it/s]
Durchschnittliche Antwortähnlichkeit: 0.8183913191958395
SentenceTransformersTokenTextSplitter, Cosine Similarity, Embedding ada 002
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_cosine_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_200_cosine_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:39<00:00, 1.05s/it]
Durchschnittliche Antwortähnlichkeit: 0.9421745395976444
SentenceTransformersTokenTextSplitter, IP Similarity, Embedding 3 large
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="200_ip_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:41<00:00, 1.07s/it]
Durchschnittliche Antwortähnlichkeit: 0.8382218615881519
SentenceTransformersTokenTextSplitter, IP Similarity, Embedding ada 002
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_200_ip_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:40<00:00, 1.06s/it]
Durchschnittliche Antwortähnlichkeit: 0.9428049017660128
SentenceTransformersTokenTextSplitter, l2 Similarity, Embedding 3 large
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-3-large")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_l2_3-large",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="200_l2_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:42<00:00, 1.08s/it]
Durchschnittliche Antwortähnlichkeit: 0.8280307023708715
SentenceTransformersTokenTextSplitter, l2 Similarity, Embedding ada 002
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_l2_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.3,
save_path="ada_200_l2_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:39<00:00, 1.05s/it]
Durchschnittliche Antwortähnlichkeit: 0.9413381270921989
Embedding Evaluation: Übersicht der Mittelwerte¶
| Emb. Modell | Distanzmetrik | Splitter | Chunks | Faithfulness | Answer Relevance | Context Precision | Context Recall | Answer Correctness | MMR | Precision@k | Recall@k | Similarity to Gold |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 3-large | cosine | recchar | 800 | 0.88 | 0.49 | 0.88 | 0.88 | 0.66 | 0.95 | 0.81 | 1.00 | 0.778 |
| ada | cosine | recchar | 800 | 0.82 | 0.84 | 0.83 | 0.91 | 0.73 | 1.00 | 1.00 | 1.00 | 0.937 |
| 3-large | IP | recchar | 800 | 0.88 | 0.49 | 0.88 | 0.88 | 0.62 | 0.95 | 0.81 | 1.00 | 0.749 |
| ada | IP | recchar | 800 | 0.82 | 0.84 | 0.81 | 0.88 | 0.74 | 1.00 | 1.00 | 1.00 | 0.918 |
| 3-large | l2 | recchar | 800 | 0.88 | 0.49 | 0.88 | 0.88 | 0.65 | 0.95 | 0.81 | 1.00 | 0.808 |
| ada | l2 | recchar | 800 | 0.84 | 0.84 | 0.83 | 0.88 | 0.76 | 1.00 | 1.00 | 1.00 | 0.918 |
| 3-large | cosine | senttrans | 200 | 0.88 | 0.49 | 0.85 | 0.95 | 0.64 | 0.91 | 0.77 | 0.95 | 0.825 |
| ada | cosine | senttrans | 200 | 0.92 | 0.84 | 0.92 | 0.95 | 0.71 | 1.00 | 1.00 | 1.00 | 0.946 |
| 3-large | IP | senttrans | 200 | 0.88 | 0.49 | 0.86 | 0.95 | 0.63 | 0.91 | 0.77 | 0.95 | 0.834 |
| ada | IP | senttrans | 200 | 0.86 | 0.84 | 0.92 | 0.95 | 0.70 | 1.00 | 1.00 | 1.00 | 0.943 |
| 3-large | l2 | senttrans | 200 | 0.88 | 0.48 | 0.84 | 0.95 | 0.68 | 0.91 | 0.77 | 0.95 | 0.835 |
| ada | l2 | senttrans | 200 | 0.92 | 0.84 | 0.92 | 0.95 | 0.75 | 1.00 | 1.00 | 1.00 | 0.942 |
Stärkster Gesamtkandidat:
Die Kombination text-embedding-ada-002 mit Cosine Similarity erzielte durchgehend hohe Werte in allen zentralen Metriken: Faithfulness, Answer Relevance, Answer Correctness sowie besonders bei Similarity to Gold (Top-Werte: 0.946, 0.943, 0.942). Dieses Modell überzeugte durch Konsistenz und Robustheit – unabhängig von Splitter oder Distanzmetrik.
Schwächster Kandidat:
Dem gegenüber zeigte sich text-embedding-3-large mit Cosine (800 Chunks) als die schwächste Variante. Trotz hoher Faithfulness (0.88) lagen Answer Relevance (0.49) und Answer Correctness deutlich unter dem Durchschnitt. Die Similarity to Gold war mit 0.778 klar unterhalb aller ada-002-Kombinationen.
Weitere Beobachtungen:
IP (Inner Product) funktioniert deutlich besser mit ada-002 als mit 3-large. Während 3-large + IP nur 0.749 erreicht, liegt ada-002 + IP bei bis zu 0.943 – ein Hinweis auf die höhere Robustheit von ada-002 gegenüber verschiedenen Metriken.
SentenceTransformersTokenTextSplitter zeigte keine signifikanten Vorteile gegenüber RecursiveCharacter-Splitting. Zwar wurde teils ein höherer Context Recall (1.00) erreicht, dies führte jedoch nicht zu merklichen Gewinnen bei den Endmetriken.
3-large zeigt über alle Konfigurationen hinweg schwache Werte bei Answer Relevance (max. 0.49), was auf eine systematische Schwäche in der semantischen Passung trotz guter Kontextabdeckung hinweist.
Retrieval-Qualität war insgesamt sehr hoch: Recall@k = 1 und Precision@k ≥ 0.77 in allen Fällen belegen ein bereits gutes und konsistentes Retrieval-Setup.
Kleinere Chunking-Größen (200 Tokens) führten insbesondere zu höheren Werten bei Context Recall und Recall@k. Dies deutet darauf hin, dass feiner segmentierte Texte den Retriever dabei unterstützen, relevante Inhalte präziser zu erfassen. Der Einfluss auf generative Metriken wie Answer Correctness oder Faithfulness war hingegen geringer.
Interpretation: Konstante Top-Werte bei ada-002
In allen Konfigurationen mit text-embedding-ada-002 erreichten Recall@k, Precision@k und MMR konstant den Maximalwert (1.00).
Das liegt daran, dass alle Modelle unter identischen Bedingungen (gleicher Retriever, Prompt und Temperatur) getestet wurden - Unterschiede wären also auf das Embedding zurückzuführen.
Die konstant hohen Werte zeigen, dass ada-002 den relevanten Chunk zuverlässig und sehr weit oben im Ranking findet, was auf eine starke semantische Strukturierung im Vektorraum hinweist.
Da Recall@k keine Streuung aufweist, eignen sich Answer Correctness, Context Recall und Similarity to Gold besser zur Unterscheidung der Embedding-Modellqualität.
Fazit - text-embedding-3-large oder text-embedding-ada-002?
Im Vergleich zeigte sich, dass das ältere text-embedding-ada-002 trotz einfacherer Architektur insgesamt die stabilere und leistungsfähigere Lösung darstellt. Besonders bei Answer Relevance, Answer Correctness und Similarity to Gold schnitt es durchgehend besser ab (zB. 0.94 vs. 0.77).
Zwar lieferte 3-large punktuell bessere Werte bei Context Precision und Faithfulness, jedoch war das Modell insgesamt inkonsistenter und weniger geeignet für den Einsatz in einem robusten RAG-System.
Für die weitere Evaluierung wurde daher die Kombination text-embedding-ada-002 + SentenceTransformersTokenTextSplitter + IP Similarity gewählt. Dieses Setup überzeugte nicht nur mit Bestwerten in Similarity to Gold, sondern auch durch ausgeglichene und hohe Werte in den embeddingsensitiven Metriken:
Context Recall, Answer Correctness, Recall@k und Similarity to Gold lagen alle auf hohem Niveau - ein deutlicher Hinweis auf die Qualität und Robustheit des gewählten Embeddings.
Eine gleichwertige Alternative stellt die Kombination mit Cosine Similarity dar, da sich die Metrik-Werte nur minimal unterscheiden.
Evaluierung Retrieval¶
Um die Auswirkungen verschiedener Retriever- und Prompting-Strategien isoliert bewerten zu können, wurden das Embedding-Modell (text-embedding-ada-002 + SentenceTransformersTokenTextSplitter + IP Similarity) sowie die Temperatur bei der Antwortgenerierung konstant gehalten.
Die Qualität der Kombinationen zeigt sich besonders in den Metriken Context Recall, Faithfulness, Answer Relevance und Answer Correctness, da diese unmittelbar davon abhängen, wie gut relevante Informationen gefunden und inhaltlich korrekt verarbeitet werden. Unterschiede in diesen Werten geben Aufschluss darüber, wie effektiv ein Retriever-Prompt-Paar passende Kontexte identifiziert und für die Antwortgenerierung nutzbar macht.
# Ausführung des Codes
evaluator = RAGAS_Evaluator(embedding_deployment="text-embedding-ada-002")
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="chain_of_thought",
temperature=0.3,
save_path="sim_k5_cot.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:17<00:00, 1.23it/s]
Durchschnittliche Antwortähnlichkeit: 0.8449529152214904
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k3",
prompt_name="simple",
temperature=0.3,
save_path="sim_k3_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:14<00:00, 1.27it/s]
Durchschnittliche Antwortähnlichkeit: 0.9366147935818292
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k3",
prompt_name="chain_of_thought",
temperature=0.3,
save_path="sim_k3_cot.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:15<00:00, 1.26it/s]
Durchschnittliche Antwortähnlichkeit: 0.8406827692445922
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="mmr_k5",
prompt_name="simple",
temperature=0.3,
save_path="mmr_k5_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:34<00:00, 1.00it/s]
Durchschnittliche Antwortähnlichkeit: 0.896906079895636
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="mmr_k5",
prompt_name="chain_of_thought",
temperature=0.3,
save_path="mmr_k5_cot.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:16<00:00, 1.24it/s]
Durchschnittliche Antwortähnlichkeit: 0.8322374389077946
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="mmr_k7",
prompt_name="simple",
temperature=0.3,
save_path="mmr_k7_simple.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [02:13<00:00, 1.41s/it]
Durchschnittliche Antwortähnlichkeit: 0.90163346467248
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="mmr_k7",
prompt_name="chain_of_thought",
temperature=0.3,
save_path="mmr7_k7_cot.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [02:09<00:00, 1.36s/it]
Durchschnittliche Antwortähnlichkeit: 0.8361902117960175
Retriever- und Prompt-Kombinationen: Übersicht der Mittelwerte¶
| Retriever | Prompt | k | Faithfulness | Answer Relevance | Context Precision | Context Recall | Answer Correctness | MMR | Precision@k | Recall@k | Similarity to Gold |
|---|---|---|---|---|---|---|---|---|---|---|---|
| similarity | simple | 5 | 0.86 | 0.84 | 0.92 | 0.95 | 0.70 | 1.00 | 1.00 | 1.00 | 0.943 |
| similarity | cot | 5 | 0.92 | 0.84 | 0.89 | 0.95 | 0.72 | 1.00 | 1.00 | 1.00 | 0.846 |
| similarity | simple | 3 | 0.90 | 0.84 | 0.99 | 0.95 | 0.68 | 1.00 | 0.60 | 1.00 | 0.933 |
| similarity | cot | 3 | 0.82 | 0.84 | 0.93 | 0.89 | 0.71 | 1.00 | 0.60 | 1.00 | 0.844 |
| mmr, fetch_k=20 | simple | 5 | 0.75 | 0.84 | 0.98 | 0.87 | 0.75 | 1.00 | 1.00 | 1.00 | 0.899 |
| mmr, fetch_k=20 | cot | 5 | 0.75 | 0.84 | 0.96 | 0.87 | 0.73 | 1.00 | 1.00 | 1.00 | 0.837 |
| mmr, fetch_k=20 | simple | 7 | 0.73 | 0.84 | 0.97 | 0.88 | 0.71 | 1.00 | 1.00 | 1.00 | 0.901 |
| mmr, fetch_k=20 | cot | 7 | 0.73 | 0.84 | 0.96 | 0.88 | 0.76 | 1.00 | 1.00 | 1.00 | 0.836 |
Evaluation der Retriever- und Prompt-Kombinationen
Für die Bewertung der Systemqualität wurden neben den Mittelwerten der Metriken auch Boxplots analysiert, um Streuung und Ausreißer sichtbar zu machen. Insgesamt zeigen sich klare Unterschiede zwischen den getesteten Kombinationen aus Retriever-Typ, Prompting-Strategie und dem Parameter k.
Beste Gesamtkombination:
Die Kombination aus similarity Retriever, einfachem Prompt (simple) und k=5 zeigte in nahezu allen Metriken die besten oder sehr gute Werte. Sie überzeugte durch hohe Werte bei Answer Correctness (0.70), Context Precision (0.92) und Similarity to Gold (0.943) - bei gleichzeitig geringer Streuung in den Boxplots. Diese Konfiguration erwies sich als besonders robust und ausgewogen.
Trade-off Precision@k und Recall@k:
In vielen Retrieval-Setups besteht ein Zielkonflikt zwischen hoher Recall-Sicherheit und Präzision. In dieser Arbeit trat dieser Zielkonflikt jedoch nicht auf, da Recall@k in allen Konfigurationen konstant bei 1.00 lag. Auch die Precision@k blieb bei k=5 und k=7 auf einem sehr hohen Niveau. Nur bei k=3 wurde eine gezielte Einschränkung der Precision (0.60) beobachtet - bedingt durch den reduzierten Suchraum.
Die Wahl von k=5 stellte somit keinen Kompromiss, sondern eine stabile und leistungsfähige Konfiguration dar.
Einfluss von Prompting:
Bei Verwendung von cot-Prompts ließ sich zwar eine höhere Faithfulness (bis 0.92) beobachten, gleichzeitig sank jedoch die Answer Correctness teils leicht, und es traten vereinzelt stärkere Ausreißer auf. Vor allem bei similarity + cot + k=3 war die Streuung auffällig, was auf eine geringere Stabilität hindeutet. Insgesamt zeigte sich, dass der simple Prompt häufig stabilere Ergebnisse liefert.
Effekte unterschiedlicher k-Werte:
Die Kombination similarity + simple + k=3 erzielte hohe Mittelwerte, litt jedoch bei Precision@k (nur 0.60), was auf eine Einschränkung im Retrieval hindeutet. Höhere k-Werte wie k=7 (bei MMR) führten hingegen zu hohen Recall-Werten und guter Kontextabdeckung - besonders in Kombination mit simple Prompt.
MMR-Retriever im Vergleich:
MMR-Strategien schnitten besonders bei Answer Correctness gut ab (bis 0.76 bei mmr + cot + k=7) und erreichten durchgängig hohe Kontextmetriken. Die Unterschiede zwischen cot und simple waren beim MMR-Retriever geringer ausgeprägt als bei Similarity, wobei simple leicht stabilere Resultate zeigte.
Schwächste Kombination:
Die Kombination similarity + cot + k=3 fiel im Vergleich deutlich ab. Trotz guter Mittelwerte in einigen Metriken traten auffällige Ausreißer auf, insbesondere bei Faithfulness und Context Recall, was auf eine geringe Zuverlässigkeit in der Antwortqualität schließen lässt.
Fazit:
Für eine ausgewogene Performance mit hoher Robustheit ist die Konfiguration similarity + simple + k=5 die beste Wahl, weshalb diese Konfiguration verwendet wird um nun die Auswirkung der Temperatur zu untersuchen. Je nach Anwendungsfall können MMR-basierte Kombinationen mit k=7 ebenfalls sinnvoll sein, insbesondere wenn maximale Kontextabdeckung im Vordergrund steht. Cot-Prompts sind nicht grundsätzlich überlegen und sollten gezielt eingesetzt werden, wenn argumentative oder schrittweise Antworten erwünscht sind.
Evaluierung Temperatur¶
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.0,
save_path="temp_0.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 97%|█████████▋| 92/95 [01:36<00:11, 3.69s/it]ERROR:ragas.executor:Exception raised in Job[0]: TimeoutError() Evaluating: 98%|█████████▊| 93/95 [03:00<00:53, 26.77s/it]ERROR:ragas.executor:Exception raised in Job[4]: TimeoutError() ERROR:ragas.executor:Exception raised in Job[40]: TimeoutError() Evaluating: 100%|██████████| 95/95 [03:09<00:00, 2.00s/it]
Durchschnittliche Antwortähnlichkeit: 0.9419080395988685
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.5,
save_path="temp_05.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:41<00:00, 1.07s/it]
Durchschnittliche Antwortähnlichkeit: 0.944691514754571
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=0.7,
save_path="temp_07.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:41<00:00, 1.07s/it]
Durchschnittliche Antwortähnlichkeit: 0.9384527929291889
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=1.0,
save_path="temp_1.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:39<00:00, 1.05s/it]
Durchschnittliche Antwortähnlichkeit: 0.924666588835609
results, ragas_metrics, ir_metrics = evaluator.run(
collection_name="chroma_senttrans_200_ip_ada-002",
retriever_name="similarity_k5",
prompt_name="simple",
temperature=2.0,
save_path="temp_2.csv",
plot=True
)
# Berechne die Antwortähnlichkeit
results = evaluator.compute_similarity_to_gold(results)
print("Durchschnittliche Antwortähnlichkeit:", results["similarity_to_gold"].mean())
Evaluating: 100%|██████████| 95/95 [01:14<00:00, 1.28it/s]
Durchschnittliche Antwortähnlichkeit: 0.9094658910848308
bei IR-Metriken hätte man noch den Treshold anpassen können (aus Zeitgründen nicht gemacht)
Temperature Evaluation: Übersicht der Mittelwerte¶
| Temperature | Faithfulness | Answer Relevance | Context Precision | Context Recall | Answer Correctness | MMR | Precision@k | Recall@k | Similarity to Gold |
|---|---|---|---|---|---|---|---|---|---|
| 0.0 | 0.85 | 0.84 | 0.92 | 0.95 | 0.75 | 1.00 | 1.00 | 1.00 | 0.940 |
| 0.5 | 0.92 | 0.84 | 0.92 | 0.95 | 0.72 | 1.00 | 1.00 | 1.00 | 0.939 |
| 0.7 | 0.92 | 0.84 | 0.90 | 0.95 | 0.74 | 1.00 | 1.00 | 1.00 | 0.938 |
| 1.0 | 0.92 | 0.84 | 0.92 | 0.95 | 0.71 | 1.00 | 1.00 | 1.00 | 0.929 |
| 2.0 | 0.92 | 0.84 | 0.91 | 0.91 | 0.74 | 1.00 | 1.00 | 1.00 | 0.919 |
Einfluss der Temperatureinstellung auf die Antwortqualität:
(Konfiguration: similarity + simple + k=5)
Nach Auswahl der besten Kombination aus Retriever, Prompt und k-Wert wurde der Einfluss der Temperatureinstellung auf die Antwortqualität untersucht. Die Temperatur steuert die Zufälligkeit der LLM-Antworten: niedrige Werte führen zu deterministischen, reproduzierbaren Antworten, während höhere Temperaturen die Ausdrucksvarianz erhöhen, jedoch potenziell zu weniger konsistenten Ergebnissen führen.
Die Mittelwerte der Metriken bleiben über alle Temperatureinstellungen hinweg auf hohem Niveau. Dennoch zeigen sich mit steigender Temperatur deutliche Unterschiede hinsichtlich Streuung, Stabilität und Antwortqualität.
Temperatur 0.0
Diese Einstellung erzielte den höchsten Wert bei Answer Correctness (0.75) sowie konstant hohe Kontextmetriken. Die Boxplots zeigten kaum Ausreißer, was auf eine hohe Konsistenz hindeutet. Diese Temperatur eignet sich besonders für verlässliche, faktenbasierte Antwortsysteme.
Temperatur 0.5
Bei leicht gesenkter Answer Correctness (0.72) blieb die Gesamtqualität sehr hoch. Die Streuung nahm geringfügig zu, blieb jedoch in einem unkritischen Bereich. Diese Einstellung bietet eine gute Balance zwischen Konsistenz und Variabilität.
Temperatur 0.7
Mit einem Mittelwert von 0.74 bei Answer Correctness und weiterhin hohen Werten in den Kontextmetriken zeigt sich diese Einstellung als robuster Kompromiss. Die leichte Zunahme der Streuung bleibt tolerierbar. Empfehlenswert, wenn etwas mehr Ausdrucksvielfalt gewünscht wird.
Temperatur 1.0
Die Verteilung der Metriken weist erstmals eine deutlichere Streuung auf. Faithfulness und Context Precision zeigten vermehrt Ausreißer, Answer Correctness sank auf 0.71. Diese Einstellung ist nur bedingt für hochwertige QA-Anwendungen geeignet.
Temperatur 2.0
Mit zunehmender Streuung in fast allen Metriken und einer tendenziell geringeren Stabilität ist diese Einstellung für standardisierte, verlässliche Anwendungen nicht mehr zu empfehlen. Der Fokus liegt hier klar auf maximaler Variabilität, auf Kosten der Antworttreue.
Fazit:
Die Temperatureinstellung hat einen spürbaren Einfluss auf die Stabilität und Qualität der generierten Antworten. Besonders zuverlässig sind Temperaturen im Bereich von 0.0 bis 0.5, wobei 0.0 maximale Determiniertheit und 0.5 eine gute Balance zwischen Konstanz und Ausdrucksvielfalt bietet. Höhere Temperaturen können gezielt für explorative oder kreative Aufgaben eingesetzt werden, sind für konsistente QA-Systeme jedoch weniger geeignet.
Manuell plausability Check¶
df_manuell_samples = pd.read_csv("../data_mc1/data_evaluierung/temp_05.csv")
for i, row in df_manuell_samples.iloc[:4, :6].iterrows():
print(f"\n--- Sample {i} ---")
for col in df_manuell_samples.columns[:6]:
print(f"{col}:\n{row[col]}\n")
--- Sample 0 --- question: What is the EU’s Green Deal Industrial Plan? relevant_text: The European counterpart to the US Inflation Reduction Act (IRA) aims to create an environment that is conducive to increasing the European Union's manufacturing capacity of “net-zero” technologies, to improve the competitiveness of European industry. relevant_text_llm: ['european commission introduces green deal industrial plan – pv magazine international : the european commission listed tax exemptions flexible aid and the promotion of local manufacturing among its key strategies for the green deal industrial plan. however the solarpower europe industry group has criticized the plan \' s lack of focus on solar. european commission president ursula von der leyen presents the green deal industrial plan. the european commission has published a new document on the green deal industrial plan that ec president ursula von der leyen announced at davos in mid january. the european counterpart to the us inflation reduction act ira aims to create an environment that is conducive to increasing the european union \' s manufacturing capacity of " net zero " technologies to improve the competitiveness of european industry. the plan proposed this week has yet to be discussed among member states and will be presented at the european summit in march. it includes proposals to make state aid more flexible mobilize european funds create a sovereign wealth fund and improve european supply chains. the state aid revisions would apply until 2025 in comparison with the ira \' s 10 year time frame. the industrial plan will be based on four pillars a predictable and simplified regulatory environment better access to finance upskilling and open trade for resilient supply chains. as part of the first pillar the', 'europe \' s green transition and energy security. dries acke policy director at solarpower europe said in a statement last week " industrial policy focus on critical renewable energy supply chains is a good thing. however we \' re worried by the lack of focus in the green deal industrial plan. we need support specifically for the bulk technologies that net zero and energy security are based on. " a more detailed extent of the plan still remains to be seen and some uncertainty as to how companies could be eligible for funding or the extent of such funding is yet to be unveiled. the ira contains a detailed list of manufacturing credits throughout the value chain to boost the us pv manufacturing industry. " we certainly welcome eu initiatives such as the green deal industrial plan. however it will be of crucial importance how exactly such initiatives will be implemented. precise details on the actions eu commission intends to take remain to be seen " says a spokesperson at polysilicon manufacturer wacker. so far one of the major differences between europe \' s funding and the ira is how manufacturers get access to it and how long the process can be says davor sutija ceo at wafer producer nexwafe. in europe the application and funding can take up to two years while in the us it will be dependent on the company', 'european solar manufacturers welcome green deal industrial plan : last week ursula von der leyen president of the european commission ec unveiled the eu \' s response to the inflation reduction act ira and china \' s dominance in the solar supply chain with the green deal industrial plan gdip which will be based on four pillars a predictable and simplified regulatory environment faster access to funding enhancing skills and open trade for resilient supply chains. if the ira has been welcomed by the us solar industry almost as the saviour to boost a domestic manufacturing industry in europe the response seems more lukewarm. manufacturers from across the value chain have welcomed the initiative yet are asking for more if the eu expects to compete on a level playing field with the likes of china which currently has a share of more than 80 of the global value chain the us and india. " the gdip is a very good first step but it has to be followed by others soon a strategic alliance of capital business and manufacturers and a plan for how to launch the industry " says udo mohrstedt ceo at module manufacturer ibc solar. trade body solarpower europe is calling on the eu to support technologies such as solar pv for europe \' s green transition and energy security. dries acke policy director at solarpower europe said', 'support the green transition. it will also explore the creation of a " critical raw materials club " to bring raw material consumers and resource rich countries together with the aim of ensuring global security of supply through a competitive diversified industrial base. the industrial plan is short on more details and does not discriminate between " net zero " technologies in its policy proposals. this is something that solarpower europe has criticized. " industrial policy focus on critical renewable energy supply chains is a good thing. however we \' re worried by the lack of focus in today \' s communication " said dries acke policy director at solarpower europe. " not all net zero technologies are in the same boat not in terms of strategic importance or even the impact they \' re feeling from the inflation reduction act. " ursula von der leyen said during the presentation of the plan that " europe is determined to lead the clean technology revolution. " she added that better access to financing will allow key industries of clean technologies to " grow rapidly. " brussels has its sights set on the extraordinary summit of eu leaders on feb. 9 and feb. 10. the meeting is expected to address the community response to subsidies from the united states and from china where announced investments in clean technologies will exceed 280 billion.', 'the 40 domestic production benchmark. " the act will enable the development in europe of projects in key sectors such as batteries solar cells hydrogen and wind turbines as well as all other projects in the connected value chains. this will help us deliver on the green deal objectives whilst ensuring a level playing field " said margrethe vestager executive vice president for a europe fit for the digital age. at the same time the ec has announced the critical raw materials act to diversify its imports of critical raw materials. it admitted that europe heavily relies on imports which are often from \' quasi monopolistic third country suppliers \' and will not be self sufficient in supplying such raw materials. therefore the eu will diversify its raw material supply chain with no more than 65 of its annual consumption of each raw material from a single third country and seek \' mutually beneficial \' partnerships with emerging'] retrieved_context: european commission introduces green deal industrial plan – pv magazine international : the european commission listed tax exemptions flexible aid and the promotion of local manufacturing among its key strategies for the green deal industrial plan. however the solarpower europe industry group has criticized the plan ' s lack of focus on solar. european commission president ursula von der leyen presents the green deal industrial plan. the european commission has published a new document on the green deal industrial plan that ec president ursula von der leyen announced at davos in mid january. the european counterpart to the us inflation reduction act ira aims to create an environment that is conducive to increasing the european union ' s manufacturing capacity of " net zero " technologies to improve the competitiveness of european industry. the plan proposed this week has yet to be discussed among member states and will be presented at the european summit in march. it includes proposals to make state aid more flexible mobilize european funds create a sovereign wealth fund and improve european supply chains. the state aid revisions would apply until 2025 in comparison with the ira ' s 10 year time frame. the industrial plan will be based on four pillars a predictable and simplified regulatory environment better access to finance upskilling and open trade for resilient supply chains. as part of the first pillar the europe ' s green transition and energy security. dries acke policy director at solarpower europe said in a statement last week " industrial policy focus on critical renewable energy supply chains is a good thing. however we ' re worried by the lack of focus in the green deal industrial plan. we need support specifically for the bulk technologies that net zero and energy security are based on. " a more detailed extent of the plan still remains to be seen and some uncertainty as to how companies could be eligible for funding or the extent of such funding is yet to be unveiled. the ira contains a detailed list of manufacturing credits throughout the value chain to boost the us pv manufacturing industry. " we certainly welcome eu initiatives such as the green deal industrial plan. however it will be of crucial importance how exactly such initiatives will be implemented. precise details on the actions eu commission intends to take remain to be seen " says a spokesperson at polysilicon manufacturer wacker. so far one of the major differences between europe ' s funding and the ira is how manufacturers get access to it and how long the process can be says davor sutija ceo at wafer producer nexwafe. in europe the application and funding can take up to two years while in the us it will be dependent on the company european solar manufacturers welcome green deal industrial plan : last week ursula von der leyen president of the european commission ec unveiled the eu ' s response to the inflation reduction act ira and china ' s dominance in the solar supply chain with the green deal industrial plan gdip which will be based on four pillars a predictable and simplified regulatory environment faster access to funding enhancing skills and open trade for resilient supply chains. if the ira has been welcomed by the us solar industry almost as the saviour to boost a domestic manufacturing industry in europe the response seems more lukewarm. manufacturers from across the value chain have welcomed the initiative yet are asking for more if the eu expects to compete on a level playing field with the likes of china which currently has a share of more than 80 of the global value chain the us and india. " the gdip is a very good first step but it has to be followed by others soon a strategic alliance of capital business and manufacturers and a plan for how to launch the industry " says udo mohrstedt ceo at module manufacturer ibc solar. trade body solarpower europe is calling on the eu to support technologies such as solar pv for europe ' s green transition and energy security. dries acke policy director at solarpower europe said support the green transition. it will also explore the creation of a " critical raw materials club " to bring raw material consumers and resource rich countries together with the aim of ensuring global security of supply through a competitive diversified industrial base. the industrial plan is short on more details and does not discriminate between " net zero " technologies in its policy proposals. this is something that solarpower europe has criticized. " industrial policy focus on critical renewable energy supply chains is a good thing. however we ' re worried by the lack of focus in today ' s communication " said dries acke policy director at solarpower europe. " not all net zero technologies are in the same boat not in terms of strategic importance or even the impact they ' re feeling from the inflation reduction act. " ursula von der leyen said during the presentation of the plan that " europe is determined to lead the clean technology revolution. " she added that better access to financing will allow key industries of clean technologies to " grow rapidly. " brussels has its sights set on the extraordinary summit of eu leaders on feb. 9 and feb. 10. the meeting is expected to address the community response to subsidies from the united states and from china where announced investments in clean technologies will exceed 280 billion. the 40 domestic production benchmark. " the act will enable the development in europe of projects in key sectors such as batteries solar cells hydrogen and wind turbines as well as all other projects in the connected value chains. this will help us deliver on the green deal objectives whilst ensuring a level playing field " said margrethe vestager executive vice president for a europe fit for the digital age. at the same time the ec has announced the critical raw materials act to diversify its imports of critical raw materials. it admitted that europe heavily relies on imports which are often from ' quasi monopolistic third country suppliers ' and will not be self sufficient in supplying such raw materials. therefore the eu will diversify its raw material supply chain with no more than 65 of its annual consumption of each raw material from a single third country and seek ' mutually beneficial ' partnerships with emerging answer: The EU’s Green Deal Industrial Plan aims to enhance the competitiveness of its net zero industry and accelerate the transition to net zero by supporting the expansion of European manufacturing of technologies, goods, and services necessary to meet climate targets. answer_llm: The EU’s Green Deal Industrial Plan is a strategy introduced by the European Commission to enhance the manufacturing capacity of "net zero" technologies, improve the competitiveness of European industry, and address challenges posed by the US Inflation Reduction Act and China's dominance in the solar supply chain. --- Sample 1 --- question: When did the cooperation between GM and Honda on fuel cell vehicles start? relevant_text: What caught our eye was a new hookup between GM and Honda. Honda was also hammering away at the challenge of introducing fuel cell vehicles to the US market. The collaboration launched in July of 2013, providing for the two companies to share the combined total of 1,200 fuel cell patents they compiled in the years leading up to 2012. relevant_text_llm: ['general motors seizes fuel cell moment with green hydrogen : green hydrogen is needed to ice the zero emission fuel cell electric cake for gm \' s silent utility rover universal superstructure vehicle platform. general motors has dropped hints about its interest in fuel cell electric vehicles over the years but apparently that is just the tip of a much bigger iceberg. the company has made some interesting moves in recent months which suggest a more holistic approach to the green hydrogen economy of the future regardless of what the skeptics may say. gm \' s interest in hydrogen caught the cleantechnica eye back in 2013 after the company introduced a demonstration fleet of 16 fuel cell electric vehicles for the us army in hawaii. the army demonstration was built on gm \' s project driveway fleet of 119 vehicles which launched in 2007 and racked up almost 3 million miles of driving in six years. what caught our eye was a new hookup between gm and honda. honda was also hammering away at the challenge of introducing fuel cell vehicles to the us market. the collaboration launched in july of 2013 providing for the two companies to share the combined total of 1 200 fuel cell patents they compiled in the years leading up to 2012. gm introduced its " surus " fuel cell electric vehicle platform in 2017 but it still didn \' t have a', 'its " surus " fuel cell electric vehicle platform in 2017 but it still didn \' t have a fuel cell ev in commercial production by 2020 though a preliminary agreement with nikola motor involving the badger fuel cell electric pickup truck suggested that activity was about to pick up. unfortunately for fcev fans nikola fell on its face following a scandal involving former ceo trevor milton. nikola has since recovered itself but the relationship with gm foundered. gm has not been idling around since then. as part of its collaboration with honda gm set its sights on developing fuel cells for heavy duty use resulting in its hydrotec suite of fuel cell systems. in 2021 gm launched a hydrogen powered flight collaboration with hydrotec and the aerospace company liebnerr. gm is also collaborating with navistar on fuel cells for trucks and with wabtec on fuel cells for locomotives. gm has also been deploying hydrotec modules as transportable charging stations for battery electric vehicles. the sticky wicket of course is the continued reliance on natural gas and other fossil resources to produce the hydrogen needed to run fuel cells. gm has a plan for that too. last november gm enlisted nel usa a unit of norway \' s nel asa to help push down the cost of electrolyzer systems and pump up the green hydrogen supply chain', 'hitch in gm \' s brightdrop battery electric delivery van production plans when its factory in canada ran short on batteries. gm is among the us automakers continuing to hold the fuel cell torch a position that the battery shortage appears to vindicate. also worth noting is the fuel cell startup nikola motors which appears to be back on its feet after stumbling a couple of years ago. if all goes according to plan nikola will bring its zero emission fuel cell trucks to the us postal service among other customers. meanwhile in may ford announced that its popular e transit delivery van will be the platform for a three year hydrogen fuel cell research project funded in part by the uk \' s advanced propulsion center. " the project will establish if hydrogen fuel cell technology can deliver more zero emission range to heavy use e transit customers travelling high mileages with maximum loads ancillary equipment such as chillers and with limited charging opportunities in the working shift " ford explained. the program involves a fleet of eight fuel cell ford e transit vans which are assembled in turkey for the european market. if the new tata ev battery plant works out it \' s possible that a fuel cell factory could be in the works eventually. back in 2021 jaguar land rover announced that it is developing a fuel cell version of the defender in the uk with an', 'cell vehicle platform courtesy of gm hydrotec. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible. a new cargo ship will use 100 wind energy to ferry goods between europe and the us without the carbon baggage. the us state of north dakota is among those not waiting around for the green hydrogen grass to grow under their feet. large or small heat pumps are a key pathway for rapid decarbonization. gm ceo mary barra suggested in a radio interview this week that there might be a next generation chevy bolt in the works..', 'jaguar land rover announced that it is developing a fuel cell version of the defender in the uk with an assist from the advanced propulsion center under a program called project zeus. tata is also getting a fuel cell assist from the government of india under the technology development and demonstration program in collaboration with the indian space research organization. last year the company showcased a fuel cell electric bus and in april it stepped up its ongoing partnership with the us firm cummins to bring more zero emission fuel cell vehicles to india. as for the us fuel cells are slowly trickling in but they have a lot of catching up to do. despite ongoing supply chain concerns plans to increase ev battery manufacturing capacity have been going through the roof in the us thanks in part to the one two punch of government incentives and low cost labor. find me on threads tinamcasey. also post tinamcasey or tinamcasey on linkedin and spoutible or casey on mastadon. image tata to build a new ev battery factory in the uk to support its ziptron electric vehicle technology image courtesy of tata motors. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible.'] retrieved_context: general motors seizes fuel cell moment with green hydrogen : green hydrogen is needed to ice the zero emission fuel cell electric cake for gm ' s silent utility rover universal superstructure vehicle platform. general motors has dropped hints about its interest in fuel cell electric vehicles over the years but apparently that is just the tip of a much bigger iceberg. the company has made some interesting moves in recent months which suggest a more holistic approach to the green hydrogen economy of the future regardless of what the skeptics may say. gm ' s interest in hydrogen caught the cleantechnica eye back in 2013 after the company introduced a demonstration fleet of 16 fuel cell electric vehicles for the us army in hawaii. the army demonstration was built on gm ' s project driveway fleet of 119 vehicles which launched in 2007 and racked up almost 3 million miles of driving in six years. what caught our eye was a new hookup between gm and honda. honda was also hammering away at the challenge of introducing fuel cell vehicles to the us market. the collaboration launched in july of 2013 providing for the two companies to share the combined total of 1 200 fuel cell patents they compiled in the years leading up to 2012. gm introduced its " surus " fuel cell electric vehicle platform in 2017 but it still didn ' t have a its " surus " fuel cell electric vehicle platform in 2017 but it still didn ' t have a fuel cell ev in commercial production by 2020 though a preliminary agreement with nikola motor involving the badger fuel cell electric pickup truck suggested that activity was about to pick up. unfortunately for fcev fans nikola fell on its face following a scandal involving former ceo trevor milton. nikola has since recovered itself but the relationship with gm foundered. gm has not been idling around since then. as part of its collaboration with honda gm set its sights on developing fuel cells for heavy duty use resulting in its hydrotec suite of fuel cell systems. in 2021 gm launched a hydrogen powered flight collaboration with hydrotec and the aerospace company liebnerr. gm is also collaborating with navistar on fuel cells for trucks and with wabtec on fuel cells for locomotives. gm has also been deploying hydrotec modules as transportable charging stations for battery electric vehicles. the sticky wicket of course is the continued reliance on natural gas and other fossil resources to produce the hydrogen needed to run fuel cells. gm has a plan for that too. last november gm enlisted nel usa a unit of norway ' s nel asa to help push down the cost of electrolyzer systems and pump up the green hydrogen supply chain hitch in gm ' s brightdrop battery electric delivery van production plans when its factory in canada ran short on batteries. gm is among the us automakers continuing to hold the fuel cell torch a position that the battery shortage appears to vindicate. also worth noting is the fuel cell startup nikola motors which appears to be back on its feet after stumbling a couple of years ago. if all goes according to plan nikola will bring its zero emission fuel cell trucks to the us postal service among other customers. meanwhile in may ford announced that its popular e transit delivery van will be the platform for a three year hydrogen fuel cell research project funded in part by the uk ' s advanced propulsion center. " the project will establish if hydrogen fuel cell technology can deliver more zero emission range to heavy use e transit customers travelling high mileages with maximum loads ancillary equipment such as chillers and with limited charging opportunities in the working shift " ford explained. the program involves a fleet of eight fuel cell ford e transit vans which are assembled in turkey for the european market. if the new tata ev battery plant works out it ' s possible that a fuel cell factory could be in the works eventually. back in 2021 jaguar land rover announced that it is developing a fuel cell version of the defender in the uk with an cell vehicle platform courtesy of gm hydrotec. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible. a new cargo ship will use 100 wind energy to ferry goods between europe and the us without the carbon baggage. the us state of north dakota is among those not waiting around for the green hydrogen grass to grow under their feet. large or small heat pumps are a key pathway for rapid decarbonization. gm ceo mary barra suggested in a radio interview this week that there might be a next generation chevy bolt in the works.. jaguar land rover announced that it is developing a fuel cell version of the defender in the uk with an assist from the advanced propulsion center under a program called project zeus. tata is also getting a fuel cell assist from the government of india under the technology development and demonstration program in collaboration with the indian space research organization. last year the company showcased a fuel cell electric bus and in april it stepped up its ongoing partnership with the us firm cummins to bring more zero emission fuel cell vehicles to india. as for the us fuel cells are slowly trickling in but they have a lot of catching up to do. despite ongoing supply chain concerns plans to increase ev battery manufacturing capacity have been going through the roof in the us thanks in part to the one two punch of government incentives and low cost labor. find me on threads tinamcasey. also post tinamcasey or tinamcasey on linkedin and spoutible or casey on mastadon. image tata to build a new ev battery factory in the uk to support its ziptron electric vehicle technology image courtesy of tata motors. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible. answer: July 2013 answer_llm: July 2013 --- Sample 2 --- question: Did Colgate-Palmolive enter into PPA agreements with solar developers? relevant_text: Scout Clean Energy, a Colorado-based renewable energy developer, owner and operator, has signed a power purchase agreement with Colgate-Palmolive for power from Scout’s 209 MW DC Markum Solar Farm near Waco, Texas. relevant_text_llm: ['scout, colgate - palmolive sign ppa for texas solar farm : scout clean energy a colorado based renewable energy developer owner and operator has signed a power purchase agreement with colgate palmolive for power from scout \' s 209 mw dc markum solar farm near waco texas. this fall scout will begin and manage project construction. markum will generate enough clean energy for the ercot grid to power approximately 32 200 homes. " virtual power purchase agreements vppas are a valuable part of our renewable energy master plan and will help us achieve our targets of net zero carbon emissions by 2040 and 100 renewable electricity across our global operations by 2030 " says ann tracy colgate palmolive chief sustainability officer in an announcement. markum is in both mclennan and bosque counties and is scheduled for delivery in 2024. the project will result in approximately 300 temporary construction jobs and three permanent full time positions when the facility begins operation. economic benefits to the community from new tax revenue over the life of the project are expected to be significant. scout clean energy is a portfolio company of brookfield renewable a publicly traded pure play renewable power platform. brookfield acquired scout at the beginning of 2023 and scout continues to execute on its significant growth plans. scout \' s legal advisor', 'agreement will help us power our community with an additional cost effective investment in clean and renewable geothermal energy that aligns with our dedication to environmentally responsible generation resources " said svp chief utility officer manuel pineda. in 2022 calpine signed a similar 100 mw ppa with the sacramento municipality utility district smud for 10 years. this ppa was scheduled to take effect on january 1 2023.', "america signed a ppa with nestle for its under construction ganado solar plus storage project in jackson county in the south east of the state and projects such as these will help the company realise its solar power goals. the firm already manages 3. 3gw of installed wind and solar capacity in texas and plans to add another 1. 8gw of solar capacity in the coming years through projects in its pipeline. the news follows a string of new manufacturing announcements in the us such as trina solar ' s decision to build a new 5gw module manufacturing facility in the country. newfound enthusiasm for domestic manufacturing could help minimise the costs of building new solar facilities in the us although it remains to be seen if this expanded manufacturing capacity will translate to growth in power generation capacity.", 'mention soaring energy costs ppas are becoming an increasingly attractive option for businesses looking to secure a clean energy supply. greek energy company mytilineos recently signed two long term ppas with keppel dc reit to supply two dublin based data centres with energy generated from irish solar farms. with their high electricity demand data centres are ideal candidates for clean energy ppas. meanwhile solar developers are increasingly seeking novel and significant finance options to develop or expand solar projects. british solar renewables bsr has recently succeeded in this arena having secured its first portfolio financing thanks to a facility from commonwealth bank of australia and lloyds bank. the newly funded portfolio comprises five solar assets in the uk and australia with a combined annual solar output of 132gwh. thank you for subscribing to the newsletter. you can opt out at any time.', 'walmart inks solar pv ppa in texas, invests in community solar across us : retail giant walmart has signed a power purchase agreement ppa with utility edp renewables north america edpr na for a 180mw solar pv project in texas us. under a 15 year ppa walmart will offtake 162mw of the pv plant and complement existing corporate ppa between the companies on 233mw of utility scale solar and wind energy as well as 36mw of distributed solar. this latest procurement brings the total renewables offtake between the companies to 395mw. " by providing meaningful economic benefits to local communities including new local jobs this project will help build a stronger community a stronger energy grid as well as contribute toward our operational clean energy goals " said frank palladino vp of renewable energy strategy at walmart. this is the latest ppa secured from edpr na in march which started construction on a 100mw solar pv plant in illinois earlier this month with solar financier and operator volt energy utility. the developers secured a 15 year ppa offtake with technology giant microsoft for that project. on top of the ppa in texas with edpr na walmart has also invested in 19 solar projects under development across the us including'] retrieved_context: scout, colgate - palmolive sign ppa for texas solar farm : scout clean energy a colorado based renewable energy developer owner and operator has signed a power purchase agreement with colgate palmolive for power from scout ' s 209 mw dc markum solar farm near waco texas. this fall scout will begin and manage project construction. markum will generate enough clean energy for the ercot grid to power approximately 32 200 homes. " virtual power purchase agreements vppas are a valuable part of our renewable energy master plan and will help us achieve our targets of net zero carbon emissions by 2040 and 100 renewable electricity across our global operations by 2030 " says ann tracy colgate palmolive chief sustainability officer in an announcement. markum is in both mclennan and bosque counties and is scheduled for delivery in 2024. the project will result in approximately 300 temporary construction jobs and three permanent full time positions when the facility begins operation. economic benefits to the community from new tax revenue over the life of the project are expected to be significant. scout clean energy is a portfolio company of brookfield renewable a publicly traded pure play renewable power platform. brookfield acquired scout at the beginning of 2023 and scout continues to execute on its significant growth plans. scout ' s legal advisor agreement will help us power our community with an additional cost effective investment in clean and renewable geothermal energy that aligns with our dedication to environmentally responsible generation resources " said svp chief utility officer manuel pineda. in 2022 calpine signed a similar 100 mw ppa with the sacramento municipality utility district smud for 10 years. this ppa was scheduled to take effect on january 1 2023. america signed a ppa with nestle for its under construction ganado solar plus storage project in jackson county in the south east of the state and projects such as these will help the company realise its solar power goals. the firm already manages 3. 3gw of installed wind and solar capacity in texas and plans to add another 1. 8gw of solar capacity in the coming years through projects in its pipeline. the news follows a string of new manufacturing announcements in the us such as trina solar ' s decision to build a new 5gw module manufacturing facility in the country. newfound enthusiasm for domestic manufacturing could help minimise the costs of building new solar facilities in the us although it remains to be seen if this expanded manufacturing capacity will translate to growth in power generation capacity. mention soaring energy costs ppas are becoming an increasingly attractive option for businesses looking to secure a clean energy supply. greek energy company mytilineos recently signed two long term ppas with keppel dc reit to supply two dublin based data centres with energy generated from irish solar farms. with their high electricity demand data centres are ideal candidates for clean energy ppas. meanwhile solar developers are increasingly seeking novel and significant finance options to develop or expand solar projects. british solar renewables bsr has recently succeeded in this arena having secured its first portfolio financing thanks to a facility from commonwealth bank of australia and lloyds bank. the newly funded portfolio comprises five solar assets in the uk and australia with a combined annual solar output of 132gwh. thank you for subscribing to the newsletter. you can opt out at any time. walmart inks solar pv ppa in texas, invests in community solar across us : retail giant walmart has signed a power purchase agreement ppa with utility edp renewables north america edpr na for a 180mw solar pv project in texas us. under a 15 year ppa walmart will offtake 162mw of the pv plant and complement existing corporate ppa between the companies on 233mw of utility scale solar and wind energy as well as 36mw of distributed solar. this latest procurement brings the total renewables offtake between the companies to 395mw. " by providing meaningful economic benefits to local communities including new local jobs this project will help build a stronger community a stronger energy grid as well as contribute toward our operational clean energy goals " said frank palladino vp of renewable energy strategy at walmart. this is the latest ppa secured from edpr na in march which started construction on a 100mw solar pv plant in illinois earlier this month with solar financier and operator volt energy utility. the developers secured a 15 year ppa offtake with technology giant microsoft for that project. on top of the ppa in texas with edpr na walmart has also invested in 19 solar projects under development across the us including answer: yes answer_llm: yes --- Sample 3 --- question: What is the status of ZeroAvia's hydrogen fuel cell electric aircraft? relevant_text: In December, the US startup ZeroAvia announced that its retrofitted 19-seat Dornier 228 hydrogen fuel cell electric aircraft has received permission to fly from the UK Civil Aviation Authority. relevant_text_llm: ['the wait for hydrogen fuel cell electric aircraft just got shorter : the us firm zeroavia is one step closer to bringing its zero emission electric aircraft to market powered by hydrogen fuel cells. the jet tracking social media account elonjet has drawn renewed attention to the role of private and corporate aircraft in blurting greenhouse gases into the atmosphere. the issue can be an embarrassing one for electric car makers and other businesses that portray themselves as planet savers. fortunately help is on the way. batteries and fuel cells are in a neck and neck race to nudge zero emission electric aircraft out of the workshed and onto the runway. batteries and fuel cells have already scaled up for a wide range of heavy duty ground applications including semi trucks locomotives and construction vehicles along with stationary energy storage systems. sending them up on an airplane is a different matter entirely but a flurry of activity this past fall indicates that zero emission aircraft are close at hand. in the battery area for example last fall the us startup eviation laid claim to the first public test flight of a 9 seat battery powered airplane. the company heart aerospace is also on track for commercial development of its 30 seat battery powered electric aircraft. hydrogen fuel cell aircraft have been emerging at a similar pace. in december the us startup zeroavia announced that its retro', 'expects to submit the paperwork for commercial versions of its za600 electric aircraft ranging from 9 to 19 seats by the end of 2023. the next step will be the delivery of powertrains by 2025 for which zeroavia seems well prepared. the company states that is has logged pre orders for 1 500 engines and has formed partnerships with seven aircraft manufacturers along with fuel and airport partnerships. as for why the uk is involved that \' s a good question considering that zeroavia \' s home base is far away in the state of washington. zeroavia maintains a headquarters in the uk where hydrogen fueled transportation has been catching on more quickly compared to the us. the uk and europe are also ahead of the us on on green hydrogen with an assist from a vigorous offshore wind industry. " low carbon hydrogen is our new home grown super fuel which will be vital for our energy security and to meet our legally binding commitment to achieve net zero by 2050 " explained the uk government in an update to its hydrogen strategy last summer. zeroavia \' s uk activity is funded through the 12. 3 million hyflyer ii project which builds on zeroavia \' s previous work with the uk government and other stakeholders. zeroavia has attracted interest from a list private sector investors as well. by december', 'aircraft have been emerging at a similar pace. in december the us startup zeroavia announced that its retrofitted 19 seat dornier 228 hydrogen fuel cell electric aircraft has received permission to fly from the uk civil aviation authority. the caa permission slip validates zeroavia \' s engineering and ground testing regimen opening the gate to commercialization. the dornier builds on zeroavia \' s earlier work on a six seat electric aircraft. the initial focus is on a range of 300 miles for the 19 seater. zeroavia anticipates bumping that up to 700 miles for 40 80 seats by 2027. the new caa permit sets the stage for a series of test flights to begin in january with a conventional engine on board for safety during the initial flights. " the 19 seat twin engine aircraft has been retrofitted in an engineering testbed configuration to incorporate zeroavia \' s hydrogen electric engine powering the propellor on its left wing operating alongside a single honeywell tpe 331 stock engine on the right for appropriate redundancy to allow the safe testing of the novel propulsion technology " zeroavia explained in a press release. if the test flights pan out zeroavia expects to submit the paperwork for commercial versions of its za600 electric aircraft ranging from 9 to 19', 'not to be outdone the us army also piloted beta \' s evotl last year. the army emphasized it is not ready to place an order but they did indicate a strong interest based on the compatibility of the electric aircrafts with the army \' s climate strategy. potential benefits also include " design flexibility reduced maintenance reduced acoustic signatures and less operations and support costs " according to the army. as of this writing military interest in fuel cell electric aircraft appears confined to unmanned aircraft with the navy exploring a futuristic " infinite flight " fuel cell system powered by solar energy. follow me on trainwreck twitter tinamcasey. photo hydrogen fuel cell electric aircraft courtesy of zeroavia. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible. a new cargo ship will use 100 wind energy to ferry goods between europe and the us without the carbon baggage. the us state of north dakota is among those not waiting around for the green hydrogen grass to grow under their feet. large or small heat pumps are a key pathway for rapid decarbonization. in sales pitches for methanol and ammonia for maritime fuels the numbers don \' t add up and', '6th generation... eviation aircraft has just announced that the order book for the all electric alice airplane has passed a total value of 2 billion. eviation is... the us hydrogen strategy was positioned in the wrong federal department. it was put in the hands of people who deal with fossil fuels... green hydrogen for energy is an economic dead end not a replacement for fossil fuel revenues and the sooner queensland policy makers internalize that... in a recent report from rethink energy lead analyst bogdan avramuta makes the point that depending on " sustainable aviation fuel " that is kerosene... i write quite a bit about unmanned electric aircraft and the benefits both for people and the environment that they come with as they... delegates to cop27 will travel to the conference with net zero emissions rather than contributing to climate change. etihad airways has partnered with world... aviation contributes significantly to greenhouse gas emissions. in the united states commercial flights produce about 805 million metric tons of carbon dioxide per year... electric manned aircraft are under development by a number of businesses although they are still in their infancy. large planes require too much energy... xpeng got a lot of headlines this week for the first global public'] retrieved_context: the wait for hydrogen fuel cell electric aircraft just got shorter : the us firm zeroavia is one step closer to bringing its zero emission electric aircraft to market powered by hydrogen fuel cells. the jet tracking social media account elonjet has drawn renewed attention to the role of private and corporate aircraft in blurting greenhouse gases into the atmosphere. the issue can be an embarrassing one for electric car makers and other businesses that portray themselves as planet savers. fortunately help is on the way. batteries and fuel cells are in a neck and neck race to nudge zero emission electric aircraft out of the workshed and onto the runway. batteries and fuel cells have already scaled up for a wide range of heavy duty ground applications including semi trucks locomotives and construction vehicles along with stationary energy storage systems. sending them up on an airplane is a different matter entirely but a flurry of activity this past fall indicates that zero emission aircraft are close at hand. in the battery area for example last fall the us startup eviation laid claim to the first public test flight of a 9 seat battery powered airplane. the company heart aerospace is also on track for commercial development of its 30 seat battery powered electric aircraft. hydrogen fuel cell aircraft have been emerging at a similar pace. in december the us startup zeroavia announced that its retro expects to submit the paperwork for commercial versions of its za600 electric aircraft ranging from 9 to 19 seats by the end of 2023. the next step will be the delivery of powertrains by 2025 for which zeroavia seems well prepared. the company states that is has logged pre orders for 1 500 engines and has formed partnerships with seven aircraft manufacturers along with fuel and airport partnerships. as for why the uk is involved that ' s a good question considering that zeroavia ' s home base is far away in the state of washington. zeroavia maintains a headquarters in the uk where hydrogen fueled transportation has been catching on more quickly compared to the us. the uk and europe are also ahead of the us on on green hydrogen with an assist from a vigorous offshore wind industry. " low carbon hydrogen is our new home grown super fuel which will be vital for our energy security and to meet our legally binding commitment to achieve net zero by 2050 " explained the uk government in an update to its hydrogen strategy last summer. zeroavia ' s uk activity is funded through the 12. 3 million hyflyer ii project which builds on zeroavia ' s previous work with the uk government and other stakeholders. zeroavia has attracted interest from a list private sector investors as well. by december aircraft have been emerging at a similar pace. in december the us startup zeroavia announced that its retrofitted 19 seat dornier 228 hydrogen fuel cell electric aircraft has received permission to fly from the uk civil aviation authority. the caa permission slip validates zeroavia ' s engineering and ground testing regimen opening the gate to commercialization. the dornier builds on zeroavia ' s earlier work on a six seat electric aircraft. the initial focus is on a range of 300 miles for the 19 seater. zeroavia anticipates bumping that up to 700 miles for 40 80 seats by 2027. the new caa permit sets the stage for a series of test flights to begin in january with a conventional engine on board for safety during the initial flights. " the 19 seat twin engine aircraft has been retrofitted in an engineering testbed configuration to incorporate zeroavia ' s hydrogen electric engine powering the propellor on its left wing operating alongside a single honeywell tpe 331 stock engine on the right for appropriate redundancy to allow the safe testing of the novel propulsion technology " zeroavia explained in a press release. if the test flights pan out zeroavia expects to submit the paperwork for commercial versions of its za600 electric aircraft ranging from 9 to 19 not to be outdone the us army also piloted beta ' s evotl last year. the army emphasized it is not ready to place an order but they did indicate a strong interest based on the compatibility of the electric aircrafts with the army ' s climate strategy. potential benefits also include " design flexibility reduced maintenance reduced acoustic signatures and less operations and support costs " according to the army. as of this writing military interest in fuel cell electric aircraft appears confined to unmanned aircraft with the navy exploring a futuristic " infinite flight " fuel cell system powered by solar energy. follow me on trainwreck twitter tinamcasey. photo hydrogen fuel cell electric aircraft courtesy of zeroavia. tina specializes in military and corporate sustainability advanced technology emerging materials biofuels and water and wastewater issues. views expressed are her own. follow her on twitter tinamcasey and spoutible. a new cargo ship will use 100 wind energy to ferry goods between europe and the us without the carbon baggage. the us state of north dakota is among those not waiting around for the green hydrogen grass to grow under their feet. large or small heat pumps are a key pathway for rapid decarbonization. in sales pitches for methanol and ammonia for maritime fuels the numbers don ' t add up and 6th generation... eviation aircraft has just announced that the order book for the all electric alice airplane has passed a total value of 2 billion. eviation is... the us hydrogen strategy was positioned in the wrong federal department. it was put in the hands of people who deal with fossil fuels... green hydrogen for energy is an economic dead end not a replacement for fossil fuel revenues and the sooner queensland policy makers internalize that... in a recent report from rethink energy lead analyst bogdan avramuta makes the point that depending on " sustainable aviation fuel " that is kerosene... i write quite a bit about unmanned electric aircraft and the benefits both for people and the environment that they come with as they... delegates to cop27 will travel to the conference with net zero emissions rather than contributing to climate change. etihad airways has partnered with world... aviation contributes significantly to greenhouse gas emissions. in the united states commercial flights produce about 805 million metric tons of carbon dioxide per year... electric manned aircraft are under development by a number of businesses although they are still in their infancy. large planes require too much energy... xpeng got a lot of headlines this week for the first global public answer: ZeroAvia's hydrogen fuel cell electric aircraft, a retrofitted 19-seat Dornier 228, has received permission to fly from the UK Civil Aviation Authority. answer_llm: ZeroAvia's hydrogen fuel cell electric aircraft has received permission to fly from the UK Civil Aviation Authority and is set to begin test flights in January.
Zur qualitativen Absicherung der quantitativen Auswertung wurde zusätzlich ein manueller Plausibilitätscheck anhand ausgewählter Stichproben durchgeführt. Dabei wurden jeweils Frage, Antwort, Kontext und LLM-generierte Antwort inhaltlich geprüft.
Die vier analysierten Beispiele zeigen durchgehend hohe inhaltliche Übereinstimmung zwischen den Antworten und dem zugrundeliegenden Kontext. Besonders die LLM-Antworten spiegeln den Inhalt der Retrieval-Passagen treffend wider, ohne signifikante Abweichungen oder Halluzinationen.
Beispielhaft sei die erste Frage („Was ist der EU Green Deal Industrial Plan?“) genannt, bei der sowohl die extrahierte Antwort als auch die generierte LLM-Antwort wesentliche Kernaussagen des Kontextes korrekt zusammenfassen - inklusive Bezug zur US-Initiative IRA sowie den vier strategischen Säulen des Plans.
Auch bei faktischen Fragen, etwa zum Beginn der Kooperation zwischen GM und Honda (Juli 2013), konnte die Information klar im Kontext lokalisiert und korrekt wiedergegeben werden.
Das Beispiel zu ZeroAvia belegt darüber hinaus, dass auch komplexere Aussagen (Genehmigung für Testflüge durch die UK Civil Aviation Authority) präzise extrahiert wurden.
Insgesamt bestätigen diese Beispiele, dass die Retrieval-Pipeline relevante Textabschnitte zuverlässig extrahiert und das LLM diese kohärent zusammenfasst – ein wichtiger Indikator für die funktionale Qualität des Gesamtsystems.
Fazit¶
Grundsätzlich lässt sich nicht pauschal ein „bestes“ Modell bestimmen - die optimale Konfiguration hängt stets vom spezifischen Anwendungsfall ab, da jede Modellkombination individuelle Stärken und Schwächen aufweist.
Beispiele für Anwendungsfälle und relevante Metrik-Schwerpunkte:
Faktenbasierte Beantwortung in domänenspezifischen Wissenssystemen (zB. Cleantech-FAQs, Compliance-Assistenz):
Faithfulness (Antwort muss belegbar sein), Answer Correctness, Recall@k (wichtige Inhalte dürfen nicht fehlen)Schnelle Informationssuche / Recherche-Assistenz (zB. journalistische Tools, technische Dokumentation):
Context Recall (alle relevanten Infos finden), Precision@k (wenig irrelevante Treffer), Answer RelevanceChatbots oder Dialogsysteme für Endnutzer (zB. Kundenservice, interne Wissens-Hilfe):
Answer Relevance (Antwort passt zur Frage), Context Precision (kein überladener Kontext), MRR (Antwort sollte früh im Retrieval liegen)Kreative Assistenzsysteme (zB. Ideengenerierung, Textentwürfe mit Faktenbezug):
Moderate Faithfulness (Kreativität vs. Faktentreue),Answer Relevance, Temperatur-Einstellungen als entscheidender Hyperparameter
Empfohlene ausgewogene Systemkonfiguration:¶
Die Evaluation erfolgte auf Grundlage verschiedener Qualitätsmetriken sowie durch ergänzende Visualisierungen mittels Boxplots. Dabei zeigte sich, dass die folgenden Komponenten in Kombination die "besten" Gesamtergebnisse lieferten:
Embedding-Modell: text-embedding-ada-002
Dieses Modell überzeugte durch konstant hohe Werte in allen embeddingsensitiven Metriken wie Context Recall, Similarity to Gold und Answer Correctness. Im Vergleich zum neueren text-embedding-3-large zeigte es eine höhere Stabilität und geringere Streuung – unabhängig von Retriever oder Splitter.Retriever: similarity
Der klassische Similarity-Retriever war in der Kombination mit einfachem Prompting und angepasstem k-Wert der zuverlässigste Ansatz. Er erreichte eine sehr hohe Trefferquote (Recall@k = 1.00) und eine ausgezeichnete Kontextpräzision.Prompting: simple
Im Vergleich zu chain-of-thought (cot) zeigte der einfache Prompt stabilere Ergebnisse bei geringerer Streuung. Cot-Prompts brachten keinen nennenswerten Vorteil im Hinblick auf die generativen Metriken, führten jedoch häufiger zu Ausreißern.Temperature: 0.5
Diese Einstellung bietet eine optimale Balance zwischen Ausdrucksvielfalt und Antwortkonsistenz. Sie zeigte durchweg stabile Werte bei allen Metriken, ohne die deterministische Kontrolle vollständig aufzugeben.
Weitere Überlegungen¶
Im Rahmen dieser Arbeit wurde ein grundlegendes Retrieval-Augmented Generation (RAG)-System umgesetzt und evaluiert. Darüber hinaus gibt es weitere Konzepte und Verfahren, deren Einbeziehung zusätzliche Erkenntnisse bringen könnte. Die folgenden Aspekte wurden im Projekt nicht implementiert, könnten jedoch in einer weiterführenden Analyse evaluiert werden::
BM25 (Best Matching 25): Ein klassischer, auf Termfrequenz basierender Retrieval-Algorithmus, der als Basislinie für moderne Dense Retriever dienen kann.
Cross-Encoder: Während Dense Retriever typischerweise separate Encodierungen für Query und Dokumente nutzen, bewertet ein Cross-Encoder die Relevanz durch gemeinsame Verarbeitung beider Texte. Cross-Encoder bieten meist höhere Genauigkeit, sind aber rechenintensiver.
Step-Back Prompting – Refining Reasoning via Abstraction: Dieses Verfahren verbessert die Modellleistung bei komplexen Aufgaben, indem es zunächst eine abstrahierte (vereinfachte) Version des Problems erzeugt und darauf basierend die ursprüngliche Frage löst.
Zero-Shot, One-Shot und Few-Shot Learning (Three-Shot): Die Untersuchung verschiedener Prompting-Strategien – insbesondere Zero-Shot (ohne Beispiel), One-Shot (ein Beispiel) und Few-Shot (z. B. drei Beispiele) – könnte Aufschluss darüber geben, wie sensitiv das Modell auf Kontextinformationen reagiert.
Threshold bei IR-Metriken: Die Einführung eines Relevanz-Schwellenwerts (Threshold) bei Information-Retrieval-Metriken wie z. B. Precision@k oder Recall@k erlaubt feinere Steuerung der Evaluation. Dies ist insbesondere relevant, wenn man zwischen „gerade noch relevant“ und „vollständig relevant“ unterscheiden möchte – etwa bei der Bewertung semantisch naher, aber nicht passgenauer Antworten.